From d19fd394983d91f1dfc7ef64cad599d94b1f3d75 Mon Sep 17 00:00:00 2001 From: Changaco Date: Fri, 19 Aug 2022 11:34:42 +0200 Subject: [PATCH] add a new translation warning and improve the old one implements https://github.com/liberapay/salon/issues/520 closes #922 --- _i18n_warning.html | 13 +++++++++++-- liberapay/i18n/base.py | 5 +++++ templates/layouts/base.html | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/_i18n_warning.html b/_i18n_warning.html index fa97558fa..6b3925f20 100644 --- a/_i18n_warning.html +++ b/_i18n_warning.html @@ -1,4 +1,13 @@ +% if state.get('partial_translation')
{{ _( - "The {language} translation of this page is not yet complete." - , language=locale + "The translation of this page from English is not yet complete. {link_start}You can contribute{link_end}." + , link_start=(''|safe).format(locale.global_tag) + , link_end=''|safe ) }}
+% elif state.get('fuzzy_translation') +
{{ _( + "This page contains machine-translated text which hasn't yet been reviewed and might be inaccurate. {link_start}You can contribute{link_end}." + , link_start=(''|safe).format(locale.global_tag) + , link_end=''|safe +) }}
+% endif diff --git a/liberapay/i18n/base.py b/liberapay/i18n/base.py index 5607bea50..75a19974e 100644 --- a/liberapay/i18n/base.py +++ b/liberapay/i18n/base.py @@ -124,6 +124,8 @@ class Locale(babel.core.Locale): s2 = msg.string if isinstance(s2, tuple): s2 = s2[0] + if msg.fuzzy: + state['fuzzy_translation'] = True if not s2: s2 = s if self.language != 'en': @@ -148,6 +150,9 @@ class Locale(babel.core.Locale): s2 = msg.string[self.catalog.plural_func(n)] except Exception as e: website.tell_sentry(e) + else: + if msg.fuzzy: + state['fuzzy_translation'] = True if not s2: s2 = s if n == 1 else p if self.language != 'en': diff --git a/templates/layouts/base.html b/templates/layouts/base.html index 75b0c6730..8a280f88f 100644 --- a/templates/layouts/base.html +++ b/templates/layouts/base.html @@ -147,7 +147,7 @@ % endif -% if state.get('partial_translation') +% if state.get('partial_translation') or state.get('fuzzy_translation') % include "_i18n_warning.html" % endif