Opened 4 years ago

Last modified 4 weeks ago

#17375 assigned Bug

'makemessages' ignores plural from 'blocktrans'

Reported by: ahagenbruch Owned by: sergeykolosov
Component: Internationalization Version: master
Severity: Normal Keywords:
Cc: pigletto, m17.admin@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
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)

issue_17375.diff (15.1 KB) - added by pigletto 3 years ago.
issue_17375.2.diff (15.6 KB) - added by pigletto 3 years ago.
patch_17375_updated.diff (13.9 KB) - added by pigletto 3 years ago.
Patch updated to current trunk

Download all attachments as: .zip

Change History (20)

comment:1 Changed 4 years ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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.

comment:2 Changed 4 years ago by aaugustin

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 3 years ago by pigletto

  • Needs tests set
  • Owner changed from nobody to pigletto

comment:4 Changed 3 years ago by pigletto

  • Needs tests unset

This issue doesn't exist anymore in current trunk (1.4).

Attached test for this specific case.

comment:5 Changed 3 years ago by pigletto

  • Status changed from new to assigned

comment:6 Changed 3 years ago by claudep

The only reason it is working in your patch is that the msgid of the problematic string in test.html has a msgctxt line.

Changed 3 years ago by pigletto

comment:7 Changed 3 years ago by pigletto

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 Changed 3 years ago by pigletto

  • Cc pigletto added

Changed 3 years ago by pigletto

comment:9 Changed 3 years ago by pigletto

Uploaded issue_17375.2.diff that uses --files-from parameter for xgettext. Now patch seems to be complete for me.

comment:10 Changed 3 years ago by ext

  • Triage Stage changed from Accepted to Ready for checkin

Looks and works OK.

comment:11 Changed 3 years ago by jezdez

This doesn't apply to trunk anymore.

comment:12 Changed 3 years ago by aaugustin

  • Has patch set
  • Patch needs improvement set
  • Triage Stage changed from Ready for checkin to Accepted

Indeed, patch no longer applies.

comment:13 Changed 3 years ago by pigletto

OK, I'm going to update it soon

Changed 3 years ago by pigletto

Patch updated to current trunk

comment:14 Changed 3 years ago by pigletto

  • Patch needs improvement unset

Patch updated

comment:15 Changed 14 months ago by claudep

#22671 was a duplicate

comment:16 Changed 12 months ago by timo

  • Patch needs improvement set

Patch no longer applies cleanly.

comment:17 Changed 4 weeks ago by sergeykolosov

  • Cc m17.admin@… added
  • Owner changed from pigletto to sergeykolosov

Working on it.

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