add a new translation warning and improve the old one

implements https://github.com/liberapay/salon/issues/520

closes #922
This commit is contained in:
Changaco 2022-08-19 11:34:42 +02:00
parent ed02c75ad5
commit d19fd39498
3 changed files with 17 additions and 3 deletions

View File

@ -1,4 +1,13 @@
% if state.get('partial_translation')
<div class="notification notification-warning top">{{ _(
"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=('<a href="https://hosted.weblate.org/engage/liberapay/{}/?utm_source=liberapay-incomplete-translation-warning">'|safe).format(locale.global_tag)
, link_end='</a>'|safe
) }}</div>
% elif state.get('fuzzy_translation')
<div class="notification notification-warning top">{{ _(
"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=('<a href="https://hosted.weblate.org/engage/liberapay/{}/?utm_source=liberapay-machine-translation-warning">'|safe).format(locale.global_tag)
, link_end='</a>'|safe
) }}</div>
% endif

View File

@ -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':

View File

@ -147,7 +147,7 @@
</div>
% endif
% if state.get('partial_translation')
% if state.get('partial_translation') or state.get('fuzzy_translation')
% include "_i18n_warning.html"
% endif