Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#33554 closed Bug (duplicate)

Only first translation being found in Jinja handlebars when multiple strings are defined

Reported by: Alex Ford Owned by: nobody
Component: Utilities Version: 3.2
Severity: Normal Keywords: translations, makemessages, jinja, handlebars, multiple strings
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When running makemessages on our project we found some strings were missing from translations in our Jinja files. After diving into utils/translation/template.py we found examples of where the translations were going wrong.

Below is an example of it working:

{{ _('Hello World') }} - This works fine and 'Hello World' is added to the translatable strings. This example has a token type VAR.

Below are 3 examples of it not working:

{{ _('Hello World') + _('Foobar') }} - 'Hello World' is added to the translatable strings but 'Foobar' is not. This example has a token type VAR. Seems to be only trying to find one word to match with and that's it, should be finding all possible words.

{{ foo(_('Hello World'), _('Foobar')) }} - Exact same as above example. This is our common use case of this bug.

{{ _('Hello World') +
   _('Foobar') }}

This example is a bit different as this doesn't find any of the words as this is seen as a token type TEXT which gets ignored.

Change History (2)

comment:1 by Carlton Gibson, 3 years ago

Hi Alex. Hmmm...

So, question, why is this not an issue for Jinga? (Or, equally, what could Django do about this?) 🤔

Edit: "...After diving into utils/translation/template.py..." — A: Because we only tokenise Django templates.

Last edited 3 years ago by Carlton Gibson (previous) (diff)

comment:2 by Carlton Gibson, 3 years ago

Resolution: duplicate
Status: newclosed

Looks like this is a duplicate of #24167 — Please follow-up Alex if investigation there reveals not.

Note: See TracTickets for help on using tickets.
Back to Top