#17375 closed Bug (fixed)
'makemessages' ignores plural from 'blocktrans'
Reported by: | ahagenbruch | Owned by: | Sergey Kolosov |
---|---|---|---|
Component: | Internationalization | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Maciej Wiśniowski, m17.admin@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I have two files with equal strings to translate, in the first file
with trans
and in the second file with blocktrans
and a plural form:
a.html: {% trans 'My string' %}
b.html: {% blocktrans count counter=mylist|length %}My string{% plural %}My strings{% endblocktrans %}
and when I run django-admin.py makemessages -l de
I get
django.po #: templates/a.html:108 #: templates/b.html:3 msgid "My string" msgstr ""
and not as you'd expect
django.po #: templates/a.html:108 #: templates/b.html:3 msgid "My string" msgid_plural "My strings" msgstr[0] "" msgstr[1] ""
I can reproduce this for similar structures in other files.
blocktrans
strings that don't have trans
equivalents in other
files correctly produce entries with plural forms in the .po file.
Attachments (3)
Change History (27)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 13 years ago
Needs tests: | set |
---|---|
Owner: | changed from | to
comment:4 by , 13 years ago
Needs tests: | unset |
---|
This issue doesn't exist anymore in current trunk (1.4).
Attached test for this specific case.
comment:5 by , 13 years ago
Status: | new → assigned |
---|
comment:6 by , 13 years ago
The only reason it is working in your patch is that the msgid of the problematic string in test.html has a msgctxt line.
by , 13 years ago
Attachment: | issue_17375.diff added |
---|
comment:7 by , 13 years ago
Ok, right, it fails for blocktrans that doesn't use 'context'. Uploaded patch solves issue as suggested by using xgettext call with multiple files at once.
One thing to modify there yet is to make use of -f, --files-from in cmd for xgettext, instead of passing great amount of parameters.
comment:8 by , 13 years ago
Cc: | added |
---|
by , 13 years ago
Attachment: | issue_17375.2.diff added |
---|
comment:9 by , 13 years ago
Uploaded issue_17375.2.diff that uses --files-from parameter for xgettext. Now patch seems to be complete for me.
comment:12 by , 13 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
Triage Stage: | Ready for checkin → Accepted |
Indeed, patch no longer applies.
comment:18 by , 9 years ago
Patch needs improvement: | unset |
---|
Created a PR with another implementation based on the original idea from Claude:
https://github.com/django/django/pull/5187
comment:20 by , 9 years ago
Patch needs improvement: | unset |
---|
PR updated: https://github.com/django/django/pull/5187
comment:21 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Claude, could you take a look?
Seems to trigger this bug: https://savannah.gnu.org/bugs/index.php?35027
One possible workaround in makemessages could be to pass a list of files to xgettext instead of concatenating messages for each individual file, as xgettext seems to properly handle the merge.