From fe78aea4f14e2d76dbdffa17c90e1d4550b1e425 Mon Sep 17 00:00:00 2001 From: Lorenz Schmid Date: Sun, 19 Nov 2017 11:28:43 +0100 Subject: [PATCH] indicate source language in results --- deepl.py | 13 ++++++++----- deepl_available_langs.py | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/deepl.py b/deepl.py index f1ff650..f082c00 100644 --- a/deepl.py +++ b/deepl.py @@ -101,16 +101,19 @@ def main(wf): translations = json.loads(response.text)['result']['translations'] target_lang = json.loads(response.text)['result']['target_lang'] or \ target_lang + source_lang = json.loads(response.text)['result']['source_lang'] for translation in translations: beams = sorted(translation['beams'], key=lambda b: -1 * b['score']) for beam in beams: item = wf.decode(beam['postprocessed_sentence']) - wf.add_item( - title=item, - valid=True, - icon=langs.AVAILABLE_LANGS[target_lang]['icon'], - arg=item) + + subtitle = 'Translated from ' + \ + langs.AVAILABLE_LANGS[source_lang]['name'] + icon = langs.AVAILABLE_LANGS[target_lang]['icon'] + + wf.add_item(title=item, subtitle=subtitle, valid=True, icon=icon, + arg=item) wf.send_feedback() diff --git a/deepl_available_langs.py b/deepl_available_langs.py index 66caa99..3321fa1 100644 --- a/deepl_available_langs.py +++ b/deepl_available_langs.py @@ -30,4 +30,4 @@ 'IT': {'name': 'Italian', 'icon': 'lang_icons/it.png'}, 'NL': {'name': 'Dutch', 'icon': 'lang_icons/nl.png'}, 'PL': {'name': 'Polish', 'icon': 'lang_icons/pl.png'} -} \ No newline at end of file +}