[Django] #21963: makemessages still ignores translations in templates with inline comment tags

23 views
Skip to first unread message

Django

unread,
Feb 6, 2014, 4:34:43 AM2/6/14
to django-...@googlegroups.com
#21963: makemessages still ignores translations in templates with inline comment
tags
-------------------------------------+-------------------------------------
Reporter: Ihor Kaharlichenko | Owner: nobody
<madkinder@…> | Status: new
Type: Bug | Version: 1.6
Component: | Keywords: makemessages, template,
Internationalization | gettext, xgettext
Severity: Normal | Has patch: 0
Triage Stage: Unreviewed | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
This bug is claimed to be fixed in #19552, though it's not.

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.

Django

unread,
Feb 26, 2014, 4:27:50 PM2/26/14
to django-...@googlegroups.com
#21963: makemessages still ignores translations in templates with inline comment
tags
-------------------------------------+-------------------------------------
Reporter: Ihor Kaharlichenko | Owner: nobody
<madkinder@…> | Status: new
Type: Bug | Version: 1.6
Component: | Resolution:
Internationalization | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: makemessages, | Patch needs improvement: 0
template, gettext, xgettext | UI/UX: 0
Has patch: 0 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by claudep):

* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:1>

Django

unread,
Mar 3, 2014, 6:52:31 AM3/3/14
to django-...@googlegroups.com
#21963: makemessages still ignores translations in templates with inline comment
tags
-------------------------------------+-------------------------------------
Reporter: Ihor Kaharlichenko | Owner: nobody
<madkinder@…> | Status: new
Type: Bug | Version: 1.6
Component: | Resolution:
Internationalization | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: makemessages, | Patch needs improvement: 0
template, gettext, xgettext | UI/UX: 0
Has patch: 0 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

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>

Django

unread,
Mar 3, 2014, 6:53:43 AM3/3/14
to django-...@googlegroups.com
#21963: makemessages still ignores translations in templates with inline comment
tags
-------------------------------------+-------------------------------------
Reporter: Ihor Kaharlichenko | Owner: nobody
<madkinder@…> | Status: new
Type: Bug | Version: 1.6
Component: | Resolution:
Internationalization | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: makemessages, | Patch needs improvement: 0
template, gettext, xgettext | UI/UX: 0
Has patch: 0 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

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>

Django

unread,
Mar 7, 2014, 7:40:30 AM3/7/14
to django-...@googlegroups.com
#21963: makemessages still ignores translations in templates with inline comment
tags
-------------------------------------+-------------------------------------
Reporter: Ihor Kaharlichenko | Owner: dzhibas
<madkinder@…> | Status: assigned
Type: Bug | Version: 1.6

Component: | Resolution:
Internationalization | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: makemessages, | Patch needs improvement: 0
template, gettext, xgettext | UI/UX: 0
Has patch: 0 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by dzhibas):

* 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>

Django

unread,
Aug 29, 2014, 12:40:37 PM8/29/14
to django-...@googlegroups.com
#21963: makemessages still ignores translations in templates with inline comment
tags
-------------------------------------+-------------------------------------
Reporter: Ihor Kaharlichenko | Owner: dzhibas
<madkinder@…> | Status: assigned
Type: Bug | Version: 1.6

Component: | Resolution:
Internationalization | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: makemessages, | Patch needs improvement: 0
template, gettext, xgettext | UI/UX: 0
Has patch: 1 |
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timgraham):

* 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>

Django

unread,
Dec 25, 2014, 1:59:51 PM12/25/14
to django-...@googlegroups.com
#21963: makemessages still ignores translations in templates with inline comment
tags
-------------------------------------+-------------------------------------
Reporter: Ihor Kaharlichenko | Owner: dzhibas
<madkinder@…> |
Type: Bug | Status: assigned
Component: | Version: 1.6
Internationalization |
Severity: Normal | Resolution:
Keywords: makemessages, | Triage Stage: Accepted
template, gettext, xgettext |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:6>

Django

unread,
Nov 4, 2016, 11:28:26 AM11/4/16
to django-...@googlegroups.com
#21963: makemessages still ignores translations in templates with inline comment
tags
-------------------------------------+-------------------------------------
Reporter: Ihor Kaharlichenko | Owner: Sergey
<madkinder@…> | Kolosov

Type: Bug | Status: assigned
Component: | Version: 1.6
Internationalization |
Severity: Normal | Resolution:
Keywords: makemessages, | Triage Stage: Accepted
template, gettext, xgettext |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sergey Kolosov):

* owner: Nikolajus Krauklis => Sergey Kolosov


Comment:

Looking into this (at DUTH '16).

--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:7>

Django

unread,
Nov 5, 2016, 9:26:15 AM11/5/16
to django-...@googlegroups.com
#21963: makemessages still ignores translations in templates with inline comment
tags
-------------------------------------+-------------------------------------
Reporter: Ihor Kaharlichenko | Owner: Sergey
<madkinder@…> | Kolosov
Type: Bug | Status: assigned
Component: | Version: 1.6
Internationalization |
Severity: Normal | Resolution:
Keywords: makemessages, | Triage Stage: Accepted
template, gettext, xgettext |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sergey Kolosov):

* needs_better_patch: 1 => 0


Comment:

PR: https://github.com/django/django/pull/7489

--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:8>

Django

unread,
Apr 6, 2017, 5:47:07 AM4/6/17
to django-...@googlegroups.com
#21963: makemessages still ignores translations in templates with inline comment
tags
-------------------------------------+-------------------------------------
Reporter: Ihor Kaharlichenko | Owner: Sergey
<madkinder@…> | Kolosov
Type: Bug | Status: assigned
Component: | Version: 1.6
Internationalization |
Severity: Normal | Resolution:
Keywords: makemessages, | Triage Stage: Accepted
template, gettext, xgettext |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Sergey Kolosov):

PR rebased: https://github.com/django/django/pull/7489

--
Ticket URL: <https://code.djangoproject.com/ticket/21963#comment:9>

Django

unread,
Feb 26, 2018, 10:43:02 AM2/26/18
to django-...@googlegroups.com
#21963: makemessages still ignores translations in templates with inline comment
tags
-------------------------------------+-------------------------------------
Reporter: Ihor Kaharlichenko | Owner: Sergey
<madkinder@…> | Kolosov
Type: Bug | Status: assigned
Component: | Version: 1.6
Internationalization |
Severity: Normal | Resolution:
Keywords: makemessages, | Triage Stage: Accepted
template, gettext, xgettext |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* 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>

Reply all
Reply to author
Forward
0 new messages