deep-translator icon indicating copy to clipboard operation
deep-translator copied to clipboard

The Google translation results returned by this lib are different from results returned by web translation.

Open Waste2Time opened this issue 10 months ago • 6 comments

deep_translator_test.py

from deep_translator import GoogleTranslator

# Use any translator you like, in this example GoogleTranslator
translated = GoogleTranslator(source='ja', target='en').translate("僕は三十七歳で、そのときボーイング747のシートに座っていた。その巨大な飛行機はぶ厚い雨雲をくぐり抜けて降下し、ハンブルク空港に着陸しようとしているところだった。十一月の冷ややかな雨が大地を暗く染め、雨合羽を着た整備工たちや、のっぺりとした空港ビルの上に立った旗や、BMWの広告板やそんな何もかもをフランドル派の陰うつな絵の背景のように見せていた。やれやれ、またドイツか、と僕は思った。")  # output -> Weiter so, du bist großartig
print(translated)

and it returns

I was 37 years old and was sitting in the seat of a Boeing 747. The giant plane went through thick rain clouds and was about to land at Hamburg Airport. The cold November rains dyed the earth darkly, with the mechanics wearing raincoats, flags standing on flat-top airport buildings, BMW billboards and everything else shining pictures of the Flemish sect. It looked like the background. Oh, I thought, Germany again.

web returns

I was 37 years old and sat in a Boeing 747. The giant plane was descending through thick rainclouds and landing at Hamburg airport. The cold November rain darkened the earth, making the coat-clad mechanics, the flags atop the plain airport building, the BMW billboard, and everything else look like the backdrop of a gloomy Flemish painting. Oh dear, Germany again, I thought.

It seems that Google is changing these undocumentary APIs, the happened to another API a few days ago. The API used by this lib also happened today. Moreover, this API seems to be unstable at the moment, with intermittent 500 errors. Has anyone else had this problem?

Waste2Time avatar Feb 07 '25 07:02 Waste2Time

It happened yesterday. The request rate is more limit and quality is reduce.

ILG2021 avatar Feb 07 '25 07:02 ILG2021

https://github.com/nidhaloff/deep-translator/issues/286

same ?

https://imgur.com/a/xfZ3Ahr

maybe "500 error" has gone...right?

-> patched by xpz3 https://github.com/nidhaloff/deep-translator/issues/289#issuecomment-2661098028

Neko-Kuroi avatar Feb 16 '25 12:02 Neko-Kuroi

Test text

"I was 37 then, strapped in my seat as the huge 747 plunged through dense cloud cover on approach to Hamburg airport. Cold November rains drenched the earth, lending everything the gloomy air of a Flemish landscape: the ground crew in waterproofs, a flag atop a squat airport building, a BMW billboard. So - Germany again."

by Jay Rubin

https://imgur.com/a/WTgmHXb

google official web translate result:

当時私は37歳で、巨大な747がハンブルク空港への進入で厚い雲を突き抜けて急降下するのを座席で見ていた。11月の冷たい雨が地面を濡らし、防水服を着た地上係員、ずんぐりとした空港ビルの頂上の旗、BMWの看板など、すべてがフランドル地方の風景の陰鬱な雰囲気を醸し出していた。そう、またドイツだ。

deep-translator:

from deep_translator import GoogleTranslator
text = "I was 37 then, strapped in my seat as the huge 747 plunged through dense cloud cover on approach to Hamburg airport. Cold November rains drenched the earth, lending everything the gloomy air of a Flemish landscape: the ground crew in waterproofs, a flag atop a squat airport building, a BMW billboard. So - Germany again."
gt = GoogleTranslator(source="auto", target="ja")

translated_ = gt.translate(text=text)
print(translated_)

result:

私は37歳でしたが、ハンブルク空港へのアプローチで巨大な747が密集した雲の覆いを突き抜けたので、私は席に縛り付けられました。寒い11月の雨が地球をびしょぬれにし、フランドルの風景の悲観的な空気をすべて貸し出しました。防水の地上乗組員、スクワット空港の建物の上の旗、BMWの看板。だから - ドイツも再び。

google unofficial API result:

#pyscript
source_lang = "auto"
target_lang = "ja"

q_texts = "&q=" + quote(text)
gt_url = f"https://translate.googleapis.com/translate_a/single?client=gtx&sl={source_lang}&tl={target_lang}&dt=t{q_texts}"
response = await fetch(gt_url)
data = await response.json()
translations = data[0]

result:

私は37歳でしたが、ハンブルク空港へのアプローチで巨大な747が密集した雲の覆いを突き抜けたので、私は席に縛り付けられました。

寒い11月の雨が地球をびしょぬれにし、フランドルの風景の悲観的な空気をすべて貸し出しました。防水の地上乗組員、スクワット空港の建物の上の旗、BMWの看板。

だから - ドイツも再び。

This seems to be more a case of the API endpoint different than a literary interpretation.

Neko-Kuroi avatar Feb 16 '25 14:02 Neko-Kuroi

deep_translator_test.py

from deep_translator import GoogleTranslator

# Use any translator you like, in this example GoogleTranslator
translated = GoogleTranslator(source='ja', target='en').translate("僕は三十七歳で、そのときボーイング747のシートに座っていた。その巨大な飛行機はぶ厚い雨雲をくぐり抜けて降下し、ハンブルク空港に着陸しようとしているところだった。十一月の冷ややかな雨が大地を暗く染め、雨合羽を着た整備工たちや、のっぺりとした空港ビルの上に立った旗や、BMWの広告板やそんな何もかもをフランドル派の陰うつな絵の背景のように見せていた。やれやれ、またドイツか、と僕は思った。")  # output -> Weiter so, du bist großartig
print(translated)

and it returns

I was 37 years old and was sitting in the seat of a Boeing 747. The giant plane went through thick rain clouds and was about to land at Hamburg Airport. The cold November rains dyed the earth darkly, with the mechanics wearing raincoats, flags standing on flat-top airport buildings, BMW billboards and everything else shining pictures of the Flemish sect. It looked like the background. Oh, I thought, Germany again.

web returns

I was 37 years old and sat in a Boeing 747. The giant plane was descending through thick rainclouds and landing at Hamburg airport. The cold November rain darkened the earth, making the coat-clad mechanics, the flags atop the plain airport building, the BMW billboard, and everything else look like the backdrop of a gloomy Flemish painting. Oh dear, Germany again, I thought.

It seems that Google is changing these undocumentary APIs, the happened to another API a few days ago. The API used by this lib also happened today. Moreover, this API seems to be unstable at the moment, with intermittent 500 errors. Has anyone else had this problem?

see this https://github.com/nidhaloff/deep-translator/issues/289#issuecomment-2664715836

xpz3 avatar Feb 18 '25 07:02 xpz3

Google translator has been really messed up in the last week, and it's the mobile version that deep-translator uses at the link https://translate.google.com/m At the regular link it seems to be fine: https://translate.google.com/

G-Pavel avatar Feb 21 '25 08:02 G-Pavel

Google translator has been really messed up in the last week, and it's the mobile version that deep-translator uses at the link https://translate.google.com/m At the regular link it seems to be fine: https://translate.google.com/

Can we modifiy the code of deep translator to use the regular link?

jianhuiliao avatar Feb 22 '25 01:02 jianhuiliao