Page MenuHomePhabricator

Several strings are not displayed localized despite translating well in shell
Closed, ResolvedPublic

Description

If you create a ticket in a topic that require statutory declarations, you'll see Statutory declaration field description in English. The same applied for Ticket xx was created message. However, in shell everything works.

>>> from django.utils import translation
>>> from django.utils.translation import ugettext_lazy as _
>>> translation.activate('cs')
>>> _('English')
'angličtina'
>>> _('Statutory declaration')
'Čestné prohlášení'
>>> _('Ticket %s is created') % 'a'
'Vytvořen tiket a.'
>>>

Event Timeline

Urbanecm moved this task from Inbox to Bugs on the WMCZ-Tracker board.

@Bjornskjald investigated this and found that Notification.fire_notification() used translation.activate() and translation.deactivate(). Once the deactivate was fired, the translation stopped working. Per https://docs.djangoproject.com/en/2.2/topics/i18n/translation/#using-translations-outside-views-and-templates, this can be fixed with translation.override(). Patch coming shortly.

Thank you @Bjornskjald!

Change 556248 had a related patch set uploaded (by Urbanecm; owner: Urbanecm):
[wikimedia-cz/tracker@master] Use translation.override() instead of translation.activate()

https://gerrit.wikimedia.org/r/556248

ptrcnull subscribed.

Change 556248 merged by jenkins-bot:
[wikimedia-cz/tracker@master] Use translation.override() instead of translation.activate()

https://gerrit.wikimedia.org/r/556248

Urbanecm claimed this task.

Ticket %s is created is fixed, I'll create a follow-up task for Statutory declaration.