msgfmt -c on po file from launchpad gives "a format specification for argument 'num' doesn't exist in 'msgstr[0]'"

Bug #490149 reported by Michael Rooney
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
Low
Unassigned

Bug Description

Hello! I've been using the translations features of Launchpad with quite a bit of success, so thanks! However on 2 of my 20 or so recently exported po files, msgfmt -c complains about errors:

michael@compassion:~/Code/wxbanker$ msgfmt -cv po/sl.po
po/sl.po:153: a format specification for argument 'num' doesn't exist in 'msgstr[0]'
po/sl.po:303: a format specification for argument 'num' doesn't exist in 'msgstr[0]'
msgfmt: found 2 fatal errors

I've also attached my de.po file which has translated some of those sections successfully. It seems to perhaps be something to do with Plural-Forms / nplurals options, but I'm not sure! Any help would be greatly appreciated, thanks for the awesome work.

Translations in Launchpad: https://translations.launchpad.net/wxbanker/trunk

Revision history for this message
Michael Rooney (mrooney) wrote :
Revision history for this message
Michael Rooney (mrooney) wrote :
Revision history for this message
Michael Rooney (mrooney) wrote :
description: updated
Revision history for this message
Данило Шеган (danilo) wrote :

Thanks for the report. I am not sure why Launchpad didn't catch a problem in the translations. With Slovenian, the problem is with this message:

#: newtransactionctrl.py:91 newtransactionctrl.py:186
#: newtransactionctrl.py:196
#, python-format
msgid "Daily"
msgid_plural "Every %(num)d days"
msgstr[0] "Dnevno"
msgstr[1] "Vsakih %(num)d dni"
msgstr[2] "Vsakih %(num)d dni"
msgstr[3] "Vsakih %(num)d dni"

msgstr[0] in Slovenian is not only for 1, but for many different values. That's why msgfmt doesn't allow it without a variable. Still, Launchpad should have caught it on input and not allowed it. I'll probably make this bug about this specific problem. Workaround for you is to clear up that message, since it's badly translated anyway. :)

With Estonian, the problem seems to be that Launchpad doesn't generate a full list of empty plural messages when some of them are not provided. I believe we have a bug for that, but can't find it right now.

Revision history for this message
Michael Rooney (mrooney) wrote :

Thanks for the update, I guess it makes sense to mark this bug as Confirmed or Triaged then (if you know the cause). I'd do it but I don't have the permissions.

If you end up finding the report for the et.po issue, please let me know.

How exactly would I fix the sl.po issue, by removing the duplicate entries so it only reads like:

#: newtransactionctrl.py:91 newtransactionctrl.py:186
#: newtransactionctrl.py:196
#, python-format
msgid "Daily"
msgid_plural "Every %(num)d days"
msgstr[0] "Dnevno"
msgstr[1] "Vsakih %(num)d dni"

?

Revision history for this message
Adi Roiban (adiroiban) wrote :

Hi

I think Danilo suggested something like this for Slovenian:

#: newtransactionctrl.py:91 newtransactionctrl.py:186
#: newtransactionctrl.py:196
#, python-format
msgid "Daily"
msgid_plural "Every %(num)d days"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""
msgstr[3] ""

Cheers

Revision history for this message
Michael Rooney (mrooney) wrote :

I'm still getting these with the latest export, so the strings with the errors don't end up getting translated in the application. Here is an example in the UI of a .po file which fails a msgfmt -c: https://translations.launchpad.net/wxbanker/trunk/+pots/wxbanker/ro/74/+translate. Is there something wrong that I'm missing? It seems like it would be useful to have those in my app instead of being untranslated.

Thanks for any tips!

Changed in rosetta:
status: New → Confirmed
Revision history for this message
Данило Шеган (danilo) wrote :

What happens with eg. Romanian is that it's missing a final plural form, and our export doesn't generate an empty one in that case to keep PO file syntax correct.

Changed in rosetta:
status: Confirmed → Triaged
importance: Undecided → High
Revision history for this message
Данило Шеган (danilo) wrote :

Note that this is not the same error as your original error with Slovenian PO file.

Revision history for this message
Данило Шеган (danilo) wrote :

It is the same as with et.po though. :)

Revision history for this message
David Planella (dpm) wrote : Re: [Bug 490149] Re: msgfmt -c on po file from launchpad gives "a format specification for argument 'num' doesn't exist in 'msgstr[0]'"

El dt 01 de 12 de 2009 a les 11:10 +0000, en/na Данило Шеган va
escriure:
> Thanks for the report. I am not sure why Launchpad didn't catch a
> problem in the translations. With Slovenian, the problem is with this
> message:
>
> #: newtransactionctrl.py:91 newtransactionctrl.py:186
> #: newtransactionctrl.py:196
> #, python-format
> msgid "Daily"
> msgid_plural "Every %(num)d days"
> msgstr[0] "Dnevno"
> msgstr[1] "Vsakih %(num)d dni"
> msgstr[2] "Vsakih %(num)d dni"
> msgstr[3] "Vsakih %(num)d dni"
>
>
> msgstr[0] in Slovenian is not only for 1, but for many different
> values. That's why msgfmt doesn't allow it without a variable. Still,
> Launchpad should have caught it on input and not allowed it. I'll
> probably make this bug about this specific problem. Workaround for you
> is to clear up that message, since it's badly translated anyway. :)
>

As far as I understand it, some languages need to translate some plural
forms without the argument to be correct (although I cannot judge
whether grammatically this particular Slovenian one makes sense).

Translations such as msgstr[0] are valid when using named arguments in
format strings in Python, such as in the example, and 'msgfmt -c' does
not interpret these as errors. The problem is only when using unnamed
arguments (e.g. %d) in python-format strings: then translations such as
msgstr[0] cause a program crash.

Here's some more info:

https://bugs.edge.launchpad.net/ubuntu/+source/language-selector/+bug/409785/comments/9

Revision history for this message
Robert Collins (lifeless) wrote :

Bug 228719 covers the plural forms issue. I'll edit the description to focus on the other aspect. This bug isn't currently in our roadmap, but I'm sure we could mentor you if you want to fix the issue yourself.

description: updated
Changed in launchpad:
importance: High → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.