← Back to team overview

schooltool-developers team mailing list archive

Dynamic i18n messages

 

Hey everybody.

I've been testing the Spanish (El Salvador) version of SchoolTool trunk and noticed some new untranslated strings. So I went to Launchpad and started translating them.

This message got my attention:

%s has no days in A%s

which is located in /src/schooltool/export/importer.py:78

So I checked that module and saw (line 78):

...
ERROR_HAS_NO_DAYS = _("%s has no days in A%s")
...

and then (line 528):

...
self.errors.append(ERROR_HAS_NO_DAYS % (data['title'], row + 1))
...

Correct me if I'm wrong, but I guess this won't work, right? I mean, it won't get translated, since i18n messages use a 'mapping' instead, correct?

I remember I asked Justas on a similar problem when I was working on the email package. Every time I had to present the user a translated message I created a new copy of the original message and used the 'mapping' parameter (src/schooltool/email/browser/email.py:323)

So in this importer case, it would be like:

...
ERROR_HAS_NO_DAYS = _("${x} has no days in A${y}")
...

and then

...
message = _(ERROR_HAS_NO_DAYS, mapping={'x': data['title'], 'y': row + 1})
self.errors.append(message)
...

Am I way off here? Is there a better solution? Is it a limitation of the i18n.message package? Or is it me who's not using it right?

Thanks.

Douglas

"... allí­ es cuando te das cuenta que las cosas malas pueden resultar bastante buenas..." - Lionel Messi

Por favor, evite enviarme adjuntos de Word, Excel o PowerPoint.
Vea http://www.gnu.org/philosophy/no-word-attachments.es.html




Follow ups