Is (incorrectly) extracted as:
{{{#!po
msgid "inactive"
msgstr ""
}}}
Whereas the following:
{{{#!html+django
{% trans 'inactive' context 'plural' %}
}}}
Is (correctly) extracted as:
{{{#!po
msgctxt "plural"
msgid "inactive"
msgstr ""
}}}
Translating the former has no effect on the template rendering, as it
lacks the context.
Translating the latter makes the translation to be correctly rendered,
both without the filter, and with the filter if added '''after'''
{{{makemessages}}} was called.
I think this is a bug with the {{{makemessages}}} command.
Environnement:
Linux Mint Debian Edition
CPython 3.4.2
Django 1.8.3
GNU gettext 0.19.3
Command used:
{{{./manage.py makemessages -v 1 -l fr}}}
{{{./manage.py compilemessages}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25297>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/25297#comment:1>
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
Comment:
If this cannot be made to work for some reason, documenting the
restriction may be helpful.
--
Ticket URL: <https://code.djangoproject.com/ticket/25297#comment:2>
Comment (by apocquet):
I think the problem may come from the `inline_re` definition in
django.utils.translation.trans_real . It it used by the `templatize`
function, which it itself called from the commandline handler.
Current:
{{{#!python
inline_re =
re.compile(r"""^\s*trans\s+((?:"[^"]*?")|(?:'[^']*?'))(\s+.*context\s+((?:"[^"]*?")|(?:'[^']*?')))?\s*""")
}}}
Possible correction:
{{{#!python
inline_re =
re.compile(r"""^\s*trans\s+((?:"[^"]*?")|(?:'[^']*?'))(?:\s*\|\s*[^\s:]+(?::(?:[^\s'":]+|(?:"[^"]*?")|(?:'[^']*?')))?)*(\s+.*context\s+((?:"[^"]*?")|(?:'[^']*?')))?\s*""")
}}}
The `(?:\s*\|\s*[^\s]+(?::(?:\s+|(?:"[^"]*?")|(?:'[^']*?'))?))*` regex
should catch and throw away any filter. I may be wrong, I don't know the
precise syntax of a filter name.
The first part is quite simple and matches a `|` followed by a filter
name. The second part (starting with `?::`) is more complex because it
must matches filter arguments, including string literals.
--
Ticket URL: <https://code.djangoproject.com/ticket/25297#comment:3>
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/5203 PR] (but has a test failure).
--
Ticket URL: <https://code.djangoproject.com/ticket/25297#comment:4>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/25297#comment:5>
* needs_better_patch: 0 => 1
Comment:
Left some comments for improvement on the pull request.
--
Ticket URL: <https://code.djangoproject.com/ticket/25297#comment:6>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/25297#comment:7>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"e7b7f94678c632791f0323f8c61ce611275605c5" e7b7f946]:
{{{
#!CommitTicketReference repository=""
revision="e7b7f94678c632791f0323f8c61ce611275605c5"
Fixed #25297 -- Allowed makemessages to work with {% trans %} tags that
use template filters.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25297#comment:8>