Open ewjoachim opened 6 years ago
Hmm, it's worse than what I thought.
Even when compiling, the python-format
tags is added by matching the regex, not by analyzing the tags, so even if I remove the written tags, I still get the failing check. No workaround :/
Workaround: use {}
formatting instead of %s
formatting. This is not applicable to django templates, sadly.
This is related to the old-school bug #35.
Related, maybe, but in my case, these are perfectly valid python format strings, no misdetection. It's just that what is done on python-format string is currently wrong.
Babel enforces a strict check (as far as I'm aware, it's not trivial to disable it) regarding
python-format
: any format variable defined in the input must be defined in the output, and more precisely, any format variable defined in the singular translation should be defined in the singular source, and any format variable defined in the plural translation should be defined in the plural source.It's all well for language that have singular/plural similar to English, but it's not the case for some languages.
See the code below.
https://github.com/python-babel/babel/blob/9e1ec18d7aff94295c65254c21356de37116ca14/babel/messages/checkers.py#L46-L59
With the
izip
, it is implicitly expected that there will be 2 translations for the 2 values (singular, plural), where there could be either one (japanese, no plural form), or >2 (polish, russian, ... with several plurals), ...The consequence is that when compiling a message like :
(excuse my poor Japanese skills ><)
with this command:
we get this error: error: locale/ja_JP/LC_MESSAGES/django.po:28: unknown named placeholder 'count'.
As far as I can tell:
The only workaround today would be tosed
-remove all#, python-format
from blocks that havemsgid_plural
(or, more broadly, all the python-format tags from the translation files that are known to have issues)--disable-check
flag or somethingmsgid
andmsgid_plural
. Anything more that this would be making a strong assumption on the translation, that could prove wrong.