Open StevanWhite opened 1 month ago
I have been testing this, and it isn't as simple as I had hoped.
While the changes allow translation into many languages that did not work before, many of the new languages do not get translated, although the GT webpage does do a translation. For instance, translate()
doesn't translate English into Wolof (wo), although it does translate into Welsh (cy), and although the GT web app translates into Wolof.
I haven't discovered a pattern. Many languages with 3-letter codes, e.g. Crimean Tatar (crh) are not translated, but Cebuano (ceb) is translated. And both Simplified and Traditional Chinese (zh-CN and zh-TW) are translated.
I have seen the web page, too, sometimes fail to translate one phrase at all (leaves it in the original language), but with a minor change to the original, the phrase is translated. This is because the service translate.googleapis.com
, accessed directly, is more restricted in the languages it translates, than the Google Translate web app.
Correction.
Not all the languages in the list I provided before are supported (without subscription) by the service at translate.googleapis.com
.
Here is the list of languages that are supported (free of restrictions) by that service, as of today.
Note it is still longer than the one in the last version of this package.
LANGUAGES = {
'af': 'Afrikaans',
'sq': 'Albanian',
'am': 'Amharic',
'ar': 'Arabic',
'hy': 'Armenian',
'as': 'Assamese',
'ay': 'Aymara',
'az': 'Azerbaijani',
'bm': 'Bambara',
'eu': 'Basque',
'be': 'Belarusian',
'bn': 'Bengali',
'bho': 'Bhojpuri',
'bs': 'Bosnian',
'bg': 'Bulgarian',
'ca': 'Catalan',
'ceb': 'Cebuano',
'ny': 'Chichewa',
'zh-CN': 'Chinese (Simplified)',
'zh-TW': 'Chinese (Traditional)',
'co': 'Corsican',
'hr': 'Croatian',
'cs': 'Czech',
'da': 'Danish',
'fa-AF': 'Dari',
'dv': 'Dhivehi',
'doi': 'Dogri',
'nl': 'Dutch',
'en': 'English',
'eo': 'Esperanto',
'et': 'Estonian',
'ee': 'Ewe',
'tl': 'Filipino',
'fi': 'Finnish',
'fr': 'French',
'fy': 'Frisian',
'gl': 'Galician',
'ka': 'Georgian',
'de': 'German',
'el': 'Greek',
'gn': 'Guarani',
'gu': 'Gujarati',
'ht': 'Haitian Creole',
'ha': 'Hausa',
'haw': 'Hawaiian',
'iw': 'Hebrew',
'hi': 'Hindi',
'hmn': 'Hmong',
'hu': 'Hungarian',
'is': 'Icelandic',
'ig': 'Igbo',
'ilo': 'Ilocano',
'id': 'Indonesian',
'ga': 'Irish',
'it': 'Italian',
'ja': 'Japanese',
'jw': 'Javanese',
'kn': 'Kannada',
'kk': 'Kazakh',
'km': 'Khmer',
'rw': 'Kinyarwanda',
'gom': 'Konkani',
'ko': 'Korean',
'kri': 'Krio',
'ku': 'Kurdish (Kurmanji)',
'ckb': 'Kurdish (Sorani)',
'ky': 'Kyrgyz',
'lo': 'Lao',
'la': 'Latin',
'lv': 'Latvian',
'ln': 'Lingala',
'lt': 'Lithuanian',
'lg': 'Luganda',
'lb': 'Luxembourgish',
'mk': 'Macedonian',
'mai': 'Maithili',
'mg': 'Malagasy',
'ms': 'Malay',
'ms-Arab': 'Malay (Jawi)',
'ml': 'Malayalam',
'mt': 'Maltese',
'mi': 'Maori',
'mr': 'Marathi',
'mni-Mtei': 'Meiteilon (Manipuri)',
'lus': 'Mizo',
'mn': 'Mongolian',
'my': 'Myanmar (Burmese)',
'ne': 'Nepali',
'bm-Nkoo': 'NKo',
'no': 'Norwegian',
'or': 'Odia (Oriya)',
'om': 'Oromo',
'ps': 'Pashto',
'fa': 'Persian',
'pl': 'Polish',
'pt': 'Portuguese (Brazil)',
'pt-PT': 'Portuguese (Portugal)',
'pa': 'Punjabi (Gurmukhi)',
'pa-Arab': 'Punjabi (Shahmukhi)',
'qu': 'Quechua',
'ro': 'Romanian',
'ru': 'Russian',
'sm': 'Samoan',
'sa': 'Sanskrit',
'gd': 'Scots Gaelic',
'nso': 'Sepedi',
'sr': 'Serbian',
'st': 'Sesotho',
'sn': 'Shona',
'sd': 'Sindhi',
'si': 'Sinhala',
'sk': 'Slovak',
'sl': 'Slovenian',
'so': 'Somali',
'es': 'Spanish',
'su': 'Sundanese',
'sw': 'Swahili',
'sv': 'Swedish',
'tg': 'Tajik',
'ta': 'Tamil',
'tt': 'Tatar',
'te': 'Telugu',
'th': 'Thai',
'ti': 'Tigrinya',
'ts': 'Tsonga',
'tr': 'Turkish',
'tk': 'Turkmen',
'ak': 'Twi',
'uk': 'Ukrainian',
'ur': 'Urdu',
'ug': 'Uyghur',
'uz': 'Uzbek',
'vi': 'Vietnamese',
'cy': 'Welsh',
'xh': 'Xhosa',
'yi': 'Yiddish',
'yo': 'Yoruba',
'zu': 'Zulu',
}
Googletrans version:
I'm submitting a ...
Current behavior:
For many languages supported by Google Translate,
translate
fails, only because they are not listed in theconstants.py
file.The
LANGUAGES
variable inconstants.py
lists 108 languages, while the current Google Translate page lists 243.For instance
throws an exception
Expected behavior:
The phrase to be translated would be passed on to Google Translate, which would attempt a translation.
Steps to reproduce:
Just try to translate an English phrase into one of the un-listed languages, say, Welsh ('cy'), as above
Related code:
This is very easy to fix. I'll make it even easier for you.
First, there are two lines in
client.py
, which screw up some of the language codes in current use by GT:Remove these.
Copy-paste the following into
constants.py
. I just compiled it directly from the list in Google Translate.Other information: