Skip to content
Snippets Groups Projects
Commit 9ed4b62d authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

make google translate plugin work when from language is "auto"

parent d6d35186
No related branches found
No related tags found
No related merge requests found
......@@ -129,7 +129,7 @@ class GoogleTranslationPlugin(GajimPlugin):
self.controls = []
self.translated_text_re = re.compile(
r'google.language.callbacks.id100\(\'22\', '
'{"translatedText":"(?P<text>[^"]*)"}, 200, null, 200\)')
'{(?P<text>[^\}]*)}, 200, null, 200\)')
@log_calls('GoogleTranslationPlugin')
def translate_text(self, account, text, from_lang, to_lang):
......@@ -146,7 +146,13 @@ class GoogleTranslationPlugin(GajimPlugin):
if not results:
return text
translated_text = self.translated_text_re.search(results).group('text')
result = self.translated_text_re.search(results)
if not result:
return text
dict_ = eval('{' + result.group('text') + '}')
translated_text = dict_.get('translatedText', '')
if translated_text:
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment