Translate comma-separated terms (#554, #535)

pull/559/head
Igor Chubin 4 years ago
parent 0b8ead03e6
commit 492f4f5e50

@ -126,11 +126,17 @@ def _save_content_and_headers(path, query, content, headers):
def translate(text, lang): 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) translated = TRANSLATIONS.get(lang, {}).get(text.lower(), text)
if text == translated:
print("%s: %s" % (lang, text))
return translated return translated
def cyr(to_translate): def cyr(to_translate):

Loading…
Cancel
Save