Animenosekai / translate

A module grouping multiple translation APIs
GNU Affero General Public License v3.0
525 stars 60 forks source link

Language auto detecting is broken in MyMemory #75

Closed ZhymabekRoman closed 1 year ago

ZhymabekRoman commented 1 year ago
➜  translate git:(main) ✗ ipython
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
Type 'copyright', 'credits' or 'license' for more information
IPython 8.8.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from translatepy.translators import MyMemoryTranslate
In [2]: dl = MyMemoryTranslate()
In [3]: dl.language("hello")

# server response
ic| request.json(): {'exception_code': None,
                     'matches': '',
                     'mtLangSupported': None,
                     'quotaFinished': None,
                     'responderId': None,
                     'responseData': {'translatedText': "'AUTODETECT' IS AN INVALID SOURCE LANGUAGE . "
                                                        'EXAMPLE: LANGPAIR=EN|IT USING 2 LETTER '
                                                        'ISO OR RFC3066 LIKE ZH-CN. ALMOST ALL '
                                                        'LANGUAGES SUPPORTED BUT SOME MAY HAVE NO '
                                                        'CONTENT'},
                     'responseDetails': "'AUTODETECT' IS AN INVALID SOURCE LANGUAGE . EXAMPLE: "
                                        'LANGPAIR=EN|IT USING 2 LETTER ISO OR RFC3066 LIKE ZH-CN. '
                                        'ALMOST ALL LANGUAGES SUPPORTED BUT SOME MAY HAVE NO '
                                        'CONTENT',
                     'responseStatus': '403'}

Same issues: https://github.com/terryyin/translate-python/issues/69 https://github.com/terryyin/translate-python/issues/77 https://github.com/terryyin/translate-python/issues/53

ZhymabekRoman commented 1 year ago

I have only one solution - write own MyMemory page parser, instead of using API, because in web version of MyMemory auto detection works properly

Animenosekai commented 1 year ago
Screenshot 0005-01-26 at 12 36 18

The autotranslation does seem to work but it returns an "Auto" language response as the source language...

This might be the reason why there is a problem with the language method

ZhymabekRoman commented 1 year ago

Closed in #95:

In [1]: from translatepy.translators.mymemory import MyMemoryTranslate

In [2]: dl = MyMemoryTranslate()

In [3]: dl.language("language")
Out[3]: LanguageResult(service=Translator(MyMemory), source='language', source_lang=Language(English))

In [4]: dl.language("Bonjour")
Out[4]: LanguageResult(service=Translator(MyMemory), source='Bonjour', source_lang=Language(French))

In [5]: