AndroidLocalizePlugin icon indicating copy to clipboard operation
AndroidLocalizePlugin copied to clipboard

Improve (default) google translator

Open DankalApps opened this issue 3 years ago • 3 comments

Google translator allows to provide 5000 words. It might be good idea to provide many strings at once, separated by semicolon (or a dot?) + space.

I have an example:

    <string name="difficulty_level1">Easy</string>
    <string name="difficulty_level2">Medium</string>
    <string name="difficulty_level3">Hard</string>
    <string name="difficulty_level4">Very hard</string>

converts to Easy; Medium; Hard; Very hard

and result on translate google: https://translate.google.com/?sl=en&tl=pl&text=Easy%3BMedium%3BHard%3BVery%20hard&op=translate

It not only requires less api calls but also gives better results. Giving some context to the separated words. In the case above, when translating to my language (and some other languages too) using your plugin hard was translated to a word meaning "solid, firm, rigid", not the correct one meaning "difficult"

DankalApps avatar Feb 15 '23 10:02 DankalApps

Thanks for your feedback. This would have two problems.

1, the separator ";" may appear in the text being translated and it is impossible to assume what the user's text is.

2, For long sentences, this may lead to a reduction in the accuracy of the translated result. This is because there are many words blended together, affecting the judgment of the translation context.

Discussions are welcome.

Airsaid avatar Feb 16 '23 02:02 Airsaid

";" separator is just an example, maybe some other symbol would be better. Take a look on this 😄 : https://translate.google.com/?sl=en&tl=pl&text=Easy%E2%98%BCMedium%E2%98%BCHard%E2%98%BCVery%20hard&op=translate

One could argue that the translation would be even better - bigger context, better translation. Google translates whole web pages this way. But that would have to be tested of course, either of us might be right.

At the very least this technique could be at least used to translate multiple single word strings.

I am planning to do some simple script in python to check this and share with you my results (for languages I know at least). Could you give me some hint on how to do this? I mean communication with google translate, not python-specific stuff. Or point me to some place where I can get needed info?

DankalApps avatar Feb 16 '23 11:02 DankalApps

To communicate with Google Translate without an API KEY, you mainly need to generate the corresponding token, which may help you: GoogleToken.

Alternatively, the web version can be used directly to compare the translation results of individual sentences and sentences mixed with other words separately.

Airsaid avatar Feb 17 '23 08:02 Airsaid