sumatrapdfreader / sumatrapdf

SumatraPDF reader
http://www.sumatrapdfreader.org
GNU General Public License v3.0
13.01k stars 1.67k forks source link

Google translation not working for multiple languages #4368

Open xit77 opened 1 week ago

xit77 commented 1 week ago

SumatraPDF version

Describe the bug Google translation with Korean language doesn't work. (Possibly some other languages too)

To Reproduce

  1. Change language to Korean.
  2. Open any document.
  3. Try to translate any word using Google translate
  4. It translate into wrong language.

Expected behavior

Translation into Korean

File that reproduces the problem

Screenshots

Additional context

Note that "ko" is ISO-639 language code for Korean. "kr" is ISO-3166 country code for Korea.

It seems that "tl=" parameter in Google translate URL is from UILanguage in setting, and UILanguage seems like country code, not language code.

I think you can just omit "tl=" parameter and default seems to be last used language or user's language.

ngoclong19 commented 1 week ago

I think this is an issue with multiple languages. For example, the query string tl in Google Translate is mapped to these values for Vietnamese, Chinese (Simplified), Chinese (Traditional) as vn, cn, tw, respectively.

According to MS document, it should be vi, zh-CN, or zh-TW. https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f Google Translate seems to follow this convention.

Maybe the problem code lies in this file do/trans_langs.go.