Here's the test case:
Template:
{{{#!django
{% load i18n %}
{# Translators: Abbreviated month name #}
{% trans "Jan" %}
{# Translators: Abbreviated month name #}{% trans "Feb" %}
{% comment %}Translators: Abbreviated month name{% endcomment %}{% trans
"Mar" %}
{# Translators: Abbreviated month name #} {% trans "Apr" %}
{% comment %}Translators: Abbreviated month name{% endcomment %} {% trans
"May" %}
{# Translators: Abbreviated month name #}
{% trans "Jun" %}
{# Translators: Abbreviated month name #}
{% trans "Jul" %}
{% comment %}Translators: Abbreviated month name{% endcomment %}
{% trans "Aug" %}
}}}
The extraction session:
{{{
$ ./manage.py version
1.6.1
$ ./manage.py makemessages -l ru -i venv
.../trans_real.py:585: TranslatorCommentWarning: The translator-targeted
comment 'Translators: Abbreviated month name' (file
app1/templates/i18n_test.html, line 6) was ignored, because it wasn't the
last item on the line.
warnings.warn(warn_msg, TranslatorCommentWarning)
.../trans_real.py:585: TranslatorCommentWarning: The translator-targeted
comment 'Translators: Abbreviated month name' (file
app1/templates/i18n_test.html, line 10) was ignored, because it wasn't the
last item on the line.
warnings.warn(warn_msg, TranslatorCommentWarning)
processing locale ru
}}}
Resulting po file:
{{{#!po
#. Translators: Abbreviated month name
#: app1/templates/i18n_test.html:4
msgid "Jan"
msgstr ""
#: app1/templates/i18n_test.html:6
msgid "Feb"
msgstr ""
#. Translators: Abbreviated month name gettext(u'Mar')
#: app1/templates/i18n_test.html:10
msgid "Apr"
msgstr ""
#. Translators: Abbreviated month name gettext(u'May')
#. Translators: Abbreviated month name
#: app1/templates/i18n_test.html:15
msgid "Jun"
msgstr ""
#. Translators: Abbreviated month name
#: app1/templates/i18n_test.html:19
msgid "Jul"
msgstr ""
#. Translators: Abbreviated month name
#: app1/templates/i18n_test.html:23
msgid "Aug"
msgstr ""
}}}
The problems:
* translations for "Mar" and "May" were completely skipped
* there was a warning for single-tag comments (for Feb and Apr), but not
for block comments (for Mar and May), which is inconsistent
* Apr and Jun got wrong comments
--
Ticket URL: <https://code.djangoproject.com/ticket/21963>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:1>
Comment (by dzhibas):
Hi,
fix should move all inline comments (with or without translators) at end
of previous line rest will be covered by xgettext
here is partial fix for comments block in same line in front of trans
which gives feeling of fix:
https://github.com/dzhibas/django/commit/64a19f6b46dda54c280c494df6958464c1f330b5
same can be done for changes made for ticket #19552 and then translators
comment will be (1) not ignored (2) in same line as translation string and
will work with block `{%comments%}` & `{#`
--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:2>
Comment (by dzhibas):
if approach is good with coredev - i can finish patch, please let me know
--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:3>
* owner: nobody => dzhibas
* status: new => assigned
Comment:
https://github.com/django/django/pull/2410
please review.
--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:4>
* has_patch: 0 => 1
Comment:
Don't forget to check "Has patch" so the ticket appears in the review
queue.
--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:5>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:6>
* owner: Nikolajus Krauklis => Sergey Kolosov
Comment:
Looking into this (at DUTH '16).
--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:7>
* needs_better_patch: 1 => 0
Comment:
PR: https://github.com/django/django/pull/7489
--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:8>
Comment (by Sergey Kolosov):
PR rebased: https://github.com/django/django/pull/7489
--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:9>
* needs_better_patch: 0 => 1
Comment:
Current patch simply reverts a number of changes from #19552. Including
adding warnings (i.e. it removes them again), which seems a loss.
It reverses the logic of a number of test cases, going against decisions
made in #19552.
I've suggested on the ticket that we try and reach a consensus on the
mailing list on the correct behaviour for each type of case. From there a
resolution (without just reverting the previous work) should be easier.
--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:10>