Commit 34095f48 authored by Michal Čihař's avatar Michal Čihař

Return fully qualified results from translate method (including name of service)

parent a7a4c654
......@@ -173,7 +173,10 @@ class MachineTranslation(object):
return []
try:
return self.download_translations(language, text)
translations = self.download_translations(language, text)
return [{'t': trans[0], 'q': trans[1], 's': self.name}
for trans in translations]
except Exception as exc:
weblate.logger.error(
'Failed to fetch translations from %s (%s)',
......
......@@ -57,7 +57,10 @@ class JSViewsTest(ViewTestCase):
data = simplejson.loads(response.content)
self.assertEqual(
data,
[['Nazdar světe!', 100], ['Ahoj světe!', 100]]
[
{'q': 100, 's': 'Dummy', 't': 'Nazdar světe!'},
{'q': 100, 's': 'Dummy', 't': 'Ahoj světe!'},
]
)
def test_get_other(self):
......
......@@ -47,8 +47,8 @@ class MachineTranslationTest(TestCase):
[]
)
self.assertEqual(
machine_translation.translate('cs', 'Hello, world!'),
[('Nazdar světe!', 100), ('Ahoj světe!', 100)]
len(machine_translation.translate('cs', 'Hello, world!')),
2
)
def test_glosbe(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment