you-apps / TranslateYou

Privacy focused translator app built with MD3
https://you-apps.net
GNU General Public License v3.0
986 stars 45 forks source link

Fix mozhi engine language code #459

Open GitGitro opened 1 month ago

GitGitro commented 1 month ago

Hi!

currently the Mozhi engine tries to query the api with the language code of 3 chars long while it should be of 2. I implemented this so that if it's 3 chars long it removes the last without breaking the languages that have 2 chars as code.

Tested and working on my end

Bnyro commented 1 month ago

I couldn't reproduce that Mozhi uses 3 char language codes, every Mozhi engine I tested returned 2 char language codes.

Have you used a specific Mozhi engine to reproduce that?

GitGitro commented 1 month ago

ok yeah sorry i tested it in a bad way, it happens only with reverso through mozhi

can the code be modified to check against only reverso maybe?

Bnyro commented 1 month ago

ok yeah sorry i tested it in a bad way, it happens only with reverso through mozhi

can the code be modified to check against only reverso maybe?

Theoretically yes, but I don't think it makes much sense. Reverso probably expects 3 character language codes, so it wouldn't work if we send 2 characters instead.

Generally, the app should automatically refresh the list of available languages when you change the Mozhi engine to Reverso, so you should never run into the issue this PR aims to address, except if there's an API error at Mozhi when fetching the languages.

Or do you have found any other ways where this issue happens too?

Bnyro commented 1 month ago

For the text to speech at Mozhi however, we should certainly use your patch to only use the first two chars, since the text to speech from Mozhi always uses Google as engine, and thus needs two character language codes.

GitGitro commented 1 month ago

Theoretically yes, but I don't think it makes much sense. Reverso probably expects 3 character language codes, so it wouldn't work if we send 2 characters instead.

the thing is reverso expect 3 but mozhi thorugh reverso 2 if you try to translate from mozhi from the browser you get this engine=reverso&from=en&to=de&text=hello as form data sent, probably because as you said the tts uses 2 char

also i'm changing the way mozhi handles languages not reverso, it should still work with only reverso as main engine, but correct me if i'm wrong here

Bnyro commented 1 month ago

the thing is reverso expect 3 but mozhi thorugh reverso 2

Oh okay, I though Mozhi through Reverso expects 3 chars.