Handling of region variants for Chinese qhen querying GT
@@ -14,6 +14,9 @@ from cli.libs import nvidia_smi
from cli.mmt.cluster import ApiException, ClusterNode
from cli.mmt.processing import XMLEncoder
+def map_language(lang):
+ l=lang.split('-')[0]
+ return lang if l == "zh" else l
class TranslateError(Exception):
def __init__(self, *args, **kwargs):
@@ -238,8 +241,8 @@ class GoogleTranslate(TranslateEngine):
def translate_text(self, text):
data = {
'model': 'nmt',
- 'source': self.source_lang.split('-')[0],
- 'target': self.target_lang.split('-')[0],
+ 'source': map_language(self.source_lang),
+ 'target': map_language(self.target_lang),
'q': text,
'key': self._key,
'userip': '.'.join(map(str, (random.randint(0, 200) for _ in range(4))))
