LiveTL / HyperChat

Improved YouTube chat with CPU/RAM optimizations, customization options, and cutting-edge features!
https://livetl.app/hyperchat
GNU Affero General Public License v3.0
239 stars 24 forks source link

[Bug]: Google translate feature translate to my native language instead of the language i select. #52

Closed NaGeL182 closed 2 years ago

NaGeL182 commented 2 years ago

Checklist

Describe the bug

Google translate translates all messages to my native language which I think it is, instead of the language I select it as.

Steps To Reproduce

  1. Enable Google translate
  2. Select a language that is not your native language
  3. Still translates to your native language, or rather what google think it is.

Expected behavior

That it translates to the language i selected.

What browsers are you seeing the problem on?

Other (Put it in the "Anything else?" section)

Anything else?

Vivaldi which is Chromium basedChromium-based

KentoNishi commented 2 years ago

oh I see, so that's why some people were saying selecting English translates to Indonesian! I'll look into this

KentoNishi commented 2 years ago

@NaGeL182 @toruzz could you try out https://github.com/LiveTL/HyperChat/releases/tag/v2.3.2 and let me know if it fixes ur issue?

toruzz commented 2 years ago

@NaGeL182 @toruzz could you try out https://github.com/LiveTL/HyperChat/releases/tag/v2.3.2 and let me know if it fixes ur issue?

It seems like it's not getting the selected target language right. When I choose English it translates into Sinhala, when I choose Afrikaans it translates into Spanish, etc.

KentoNishi commented 2 years ago

pain peko

JensenLenard commented 2 years ago

I played a bit around using the v2.3.2 version of Hyperchat and the current master of the iframe-translator and it seems that the list of target languages is being translated, which causes some weird issues with the array indices. e.g. Using a German system the list of languages which are used to select the correct target is something like:

Deutsch (German) Afrikaans Albanisch Amharisch

The list is translated and later sorted using those translated names. Another interesting exception is that the system language, German, is at the start of the list.

Selecting English as the target, seems to produce messages in Filipino. Looking again at the 2 lists we can see that English is at the index of 21 in the list used by the iframe-translator library. Looking at the German list we can see Filipino at that position in the list. Similarly you can get German messages by selecting Afrikaans in the UI because the entry for "German" has the index 0.

My JavaScript/Typescript is sadly not that good which is why I can't create a fix for that problem, but maybe you can use the provided information to fetch the correct list of languages, without any applied translations

list-of-languages .

KentoNishi commented 2 years ago

I pinned down the issue to the language drop down being translated too, yeah. Haven't been able to find a good fix yet

KentoNishi commented 2 years ago

@JensenLenard

Could you screenshot the output for these two variables inside the hidden iframe? I'm in the US so it makes it a bit harder for me to test.

google.translate.TranslateElement.getInstance().B
google.translate.TranslateElement.getInstance().Ba

i'd appreciate if you could just paste these 2 lines into the console within the iframe context and lemme know what the two outputs look like (either copy-paste or screenshot).

image

JensenLenard commented 2 years ago

@KentoNishi image

Content of the first line:

{
    "de": "Deutsch",
    "af": "Afrikaans",
    "sq": "Albanisch",
    "am": "Amharisch",
    "ar": "Arabisch",
    "hy": "Armenisch",
    "az": "Aserbaidschanisch",
    "eu": "Baskisch",
    "be": "Belarussisch",
    "bn": "Bengalisch",
    "my": "Birmanisch",
    "bs": "Bosnisch",
    "bg": "Bulgarisch",
    "ceb": "Cebuano",
    "ny": "Chichewa",
    "zh-TW": "Chinesisch (traditionell)",
    "zh-CN": "Chinesisch (vereinfacht)",
    "da": "Dänisch",
    "en": "Englisch",
    "eo": "Esperanto",
    "et": "Estnisch",
    "tl": "Filipino",
    "fi": "Finnisch",
    "fr": "Französisch",
    "fy": "Friesisch",
    "gl": "Galizisch",
    "ka": "Georgisch",
    "el": "Griechisch",
    "gu": "Gujarati",
    "ht": "Haitianisch",
    "ha": "Hausa",
    "haw": "Hawaiisch",
    "iw": "Hebräisch",
    "hi": "Hindi",
    "hmn": "Hmong",
    "ig": "Igbo",
    "id": "Indonesisch",
    "ga": "Irisch",
    "is": "Isländisch",
    "it": "Italienisch",
    "ja": "Japanisch",
    "jw": "Javanisch",
    "yi": "Jiddisch",
    "kn": "Kannada",
    "kk": "Kasachisch",
    "ca": "Katalanisch",
    "km": "Khmer",
    "rw": "Kinyarwanda",
    "ky": "Kirgisisch",
    "ko": "Koreanisch",
    "co": "Korsisch",
    "hr": "Kroatisch",
    "ku": "Kurdisch (Kurmandschi)",
    "lo": "Lao",
    "la": "Lateinisch",
    "lv": "Lettisch",
    "lt": "Litauisch",
    "lb": "Luxemburgisch",
    "mg": "Malagasy",
    "ml": "Malayalam",
    "ms": "Malaysisch",
    "mt": "Maltesisch",
    "mi": "Maori",
    "mr": "Marathi",
    "mk": "Mazedonisch",
    "mn": "Mongolisch",
    "ne": "Nepalesisch",
    "nl": "Niederländisch",
    "no": "Norwegisch",
    "or": "Odia (Oriya)",
    "ps": "Paschtu",
    "fa": "Persisch",
    "pl": "Polnisch",
    "pt": "Portugiesisch",
    "pa": "Punjabi",
    "ro": "Rumänisch",
    "ru": "Russisch",
    "sm": "Samoanisch",
    "gd": "Schottisch-Gälisch",
    "sv": "Schwedisch",
    "sr": "Serbisch",
    "st": "Sesotho",
    "sn": "Shona",
    "sd": "Sindhi",
    "si": "Singhalesisch",
    "sk": "Slowakisch",
    "sl": "Slowenisch",
    "so": "Somali",
    "es": "Spanisch",
    "sw": "Suaheli",
    "su": "Sundanesisch",
    "tg": "Tadschikisch",
    "ta": "Tamil",
    "tt": "Tatarisch",
    "te": "Telugu",
    "th": "Thailändisch",
    "cs": "Tschechisch",
    "tr": "Türkisch",
    "tk": "Turkmenisch",
    "ug": "Uigurisch",
    "uk": "Ukrainisch",
    "hu": "Ungarisch",
    "ur": "Urdu",
    "uz": "Usbekisch",
    "vi": "Vietnamesisch",
    "cy": "Walisisch",
    "xh": "Xhosa",
    "yo": "Yoruba",
    "zu": "Zulu"
}

Content of 2nd line:

{
    "de": "Deutsch",
    "af": "Afrikaans",
    "sq": "Albanisch",
    "am": "Amharisch",
    "ar": "Arabisch",
    "hy": "Armenisch",
    "az": "Aserbaidschanisch",
    "eu": "Baskisch",
    "be": "Belarussisch",
    "bn": "Bengalisch",
    "my": "Birmanisch",
    "bs": "Bosnisch",
    "bg": "Bulgarisch",
    "ceb": "Cebuano",
    "ny": "Chichewa",
    "zh-TW": "Chinesisch (traditionell)",
    "zh-CN": "Chinesisch (vereinfacht)",
    "da": "Dänisch",
    "en": "Englisch",
    "eo": "Esperanto",
    "et": "Estnisch",
    "tl": "Filipino",
    "fi": "Finnisch",
    "fr": "Französisch",
    "fy": "Friesisch",
    "gl": "Galizisch",
    "ka": "Georgisch",
    "el": "Griechisch",
    "gu": "Gujarati",
    "ht": "Haitianisch",
    "ha": "Hausa",
    "haw": "Hawaiisch",
    "iw": "Hebräisch",
    "hi": "Hindi",
    "hmn": "Hmong",
    "ig": "Igbo",
    "id": "Indonesisch",
    "ga": "Irisch",
    "is": "Isländisch",
    "it": "Italienisch",
    "ja": "Japanisch",
    "jw": "Javanisch",
    "yi": "Jiddisch",
    "kn": "Kannada",
    "kk": "Kasachisch",
    "ca": "Katalanisch",
    "km": "Khmer",
    "rw": "Kinyarwanda",
    "ky": "Kirgisisch",
    "ko": "Koreanisch",
    "co": "Korsisch",
    "hr": "Kroatisch",
    "ku": "Kurdisch (Kurmandschi)",
    "lo": "Lao",
    "la": "Lateinisch",
    "lv": "Lettisch",
    "lt": "Litauisch",
    "lb": "Luxemburgisch",
    "mg": "Malagasy",
    "ml": "Malayalam",
    "ms": "Malaysisch",
    "mt": "Maltesisch",
    "mi": "Maori",
    "mr": "Marathi",
    "mk": "Mazedonisch",
    "mn": "Mongolisch",
    "ne": "Nepalesisch",
    "nl": "Niederländisch",
    "no": "Norwegisch",
    "or": "Odia (Oriya)",
    "ps": "Paschtu",
    "fa": "Persisch",
    "pl": "Polnisch",
    "pt": "Portugiesisch",
    "pa": "Punjabi",
    "ro": "Rumänisch",
    "ru": "Russisch",
    "sm": "Samoanisch",
    "gd": "Schottisch-Gälisch",
    "sv": "Schwedisch",
    "sr": "Serbisch",
    "st": "Sesotho",
    "sn": "Shona",
    "sd": "Sindhi",
    "si": "Singhalesisch",
    "sk": "Slowakisch",
    "sl": "Slowenisch",
    "so": "Somali",
    "es": "Spanisch",
    "sw": "Suaheli",
    "su": "Sundanesisch",
    "tg": "Tadschikisch",
    "ta": "Tamil",
    "tt": "Tatarisch",
    "te": "Telugu",
    "th": "Thailändisch",
    "cs": "Tschechisch",
    "tr": "Türkisch",
    "tk": "Turkmenisch",
    "ug": "Uigurisch",
    "uk": "Ukrainisch",
    "hu": "Ungarisch",
    "ur": "Urdu",
    "uz": "Usbekisch",
    "vi": "Vietnamesisch",
    "cy": "Walisisch",
    "xh": "Xhosa",
    "yo": "Yoruba",
    "zu": "Zulu"
}

I hope this helps

KentoNishi commented 2 years ago

yep perfect, thanks so much! I know how to fix this now I think 🙂

KentoNishi commented 2 years ago

https://github.com/LiveTL/HyperChat/releases/tag/v2.4.1 (beta)