Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Please check your translation format strings

26 views
Skip to first unread message

Malcolm Tredinnick

unread,
Apr 5, 2007, 11:41:03 AM4/5/07
to Djang...@googlegroups.com
Hi guys,

I have checked in (in revision [4934]) a change to compile-messages.py
so that it now checks to make sure the format specifiers in Python
strings are correct in the translated strings. We should have been doing
this all along.

Can everybody please run

bin/compile-messages.py -l XX

(where XX is your locale) and then fix any errors.

It is very easy to mess up the format strings. For example, in es_AR
(which is the case that prompted this change), one example is

msgid "Change password: %s"
msgstr "Cambiar contraseña: %S"

We can see here that a capital 'S' is used in the msgstr. Sadly, %S is
not a Python format string. Only %s is. So this would lead to a crash in
Django. Similarly, in the same file:

msgid "The %(verbose_name)s was created successfully."
msgstr "Se creó con éxito %(verbose_name)."

Here, the 's' at the end of "%(verbose_name)s" has been accidentally
left off. This, again, causes a crash because it generates a syntax
error when this string is used in the code.

I'm not picking on es_AR here. It's by no means the worst offender. It
was just the example we noticed. These errors are not trivial problems.
They will actually cause Django to stop working, much to the
disappointment of the users you are trying to help.

So can everybody please check your files and upload patches to Trac to
fix the problems.

Thanks,
Malcolm

Mario Gonzalez

unread,
Apr 5, 2007, 11:45:43 AM4/5/07
to Djang...@googlegroups.com
On 05/04/07, Malcolm Tredinnick <mal...@pointy-stick.com> wrote:
>
> I have checked in (in revision [4934]) a change to compile-messages.py
> so that it now checks to make sure the format specifiers in Python
> strings are correct in the translated strings. We should have been doing
> this all along.
>
> Can everybody please run
>
> bin/compile-messages.py -l XX
>

bin/compile-messages.py -l es

works for me.

>

--
http://www.advogato.org/person/mgonzalez/

Malcolm Tredinnick

unread,
Apr 5, 2007, 12:00:21 PM4/5/07
to Djang...@googlegroups.com
On Fri, 2007-04-06 at 01:41 +1000, Malcolm Tredinnick wrote:
> Hi guys,
>
> I have checked in (in revision [4934]) a change to compile-messages.py
> so that it now checks to make sure the format specifiers in Python
> strings are correct in the translated strings. We should have been doing
> this all along.
>
> Can everybody please run
>
> bin/compile-messages.py -l XX
>
> (where XX is your locale) and then fix any errors.

To be a bit more specific, the following locales have errors right now:

1 ca
1 cy
1 el
2 es_AR
1 fr
3 kn
3 no
1 pl
4 pt
18 te
1 zh_TW

where the first number is the number of errors related to format
string.

Regards,
Malcolm

ludvig.ericson

unread,
Apr 6, 2007, 2:14:43 PM4/6/07
to Django I18N
Fixed Norweigan (no) - http://code.djangoproject.com/ticket/3950

On Apr 5, 6:00 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:

pavithran

unread,
Apr 9, 2007, 5:38:36 AM4/9/07
to Djang...@googlegroups.com
I am the maintainer of the locale te
While I do compilation I get only 3 warnings.

$ bin/make-messages.py -l te
processing language te
errors happened while running xgettext on doc.py
./contrib/admin/views/doc.py:171: warning: 'msgid' format string with unnamed arguments cannot be properly localized:
                                           The translator cannot reorder the arguments.
                                           Please consider using a format string with named arguments,
                                           and a mapping instead of a tuple for the arguments.
./contrib/admin/views/doc.py:183: warning: 'msgid' format string with unnamed arguments cannot be properly localized:
                                           The translator cannot reorder the arguments.
                                           Please consider using a format string with named arguments,
                                           and a mapping instead of a tuple for the arguments.
./contrib/admin/views/doc.py:214: warning: 'msgid' format string with unnamed arguments cannot be properly localized:
                                           The translator cannot reorder the arguments.
                                           Please consider using a format string with named arguments,
                                           and a mapping instead of a tuple for the arguments.



I am unable to correct the warnings ...I hope someone would help me with correction of the warnings ..

--
pavithran shakamuri
www.look-pavi.blogspot.com
mobile: 91-9885272195

Malcolm Tredinnick

unread,
Apr 9, 2007, 5:49:36 AM4/9/07
to Djang...@googlegroups.com
On Mon, 2007-04-09 at 15:08 +0530, pavithran wrote:
[...]

>
> I am the maintainer of the locale te
> While I do compilation I get only 3 warnings.
>
> $ bin/make-messages.py -l te
> processing language te
> errors happened while running xgettext on doc.py
[... snipped ...]

>
> I am unable to correct the warnings ...I hope someone would help me
> with correction of the warnings ..

It looks like you are not using an up-to-date checkout of the code.
Those warnings were all fixed a while ago (and they're just warnings,
not errors).

However, the problem I was pointing to in my original post is shown when
you run compile-messages.py (not make-messages.py).

So, please ensure that

(a) you are running the latest subversion checkout of the code. When you
run "svn update" it should report that you are at something like
revision 4970, which is the latest as I type this sentence.

(b) That you also look at the error messages returned by running
bin/compile-messages.py -l te, which shows a *lot* of errors where you
have not copied the format strings correct (anything that looks like "%
s" or "%(something)s" has to be copied precisely and the 's' may be a
'd' or 'x' or 'i', possibly).

Regards,
Malcolm


Reply all
Reply to author
Forward
0 new messages