From 492f4f5e50419e3b3d4a05b0408d78b44e34cc5d Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sat, 2 Jan 2021 22:48:17 +0100 Subject: [PATCH] Translate comma-separated terms (#554, #535) --- bin/proxy.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/proxy.py b/bin/proxy.py index 95809e0..16a6598 100755 --- a/bin/proxy.py +++ b/bin/proxy.py @@ -126,11 +126,17 @@ def _save_content_and_headers(path, query, content, headers): def translate(text, lang): """ - Translate `text` into `lang` + Translate `text` into `lang`. + If `text` is comma-separated, translate each term independently. + If no translation found, leave it untouched. """ + + if "," in text: + terms = text.split(",") + translated_terms = [translate(term.strip(), lang) for term in terms] + return ", ".join(translated_terms) + translated = TRANSLATIONS.get(lang, {}).get(text.lower(), text) - if text == translated: - print("%s: %s" % (lang, text)) return translated def cyr(to_translate):