Hey Marcelo,

On Thu, 2007-04-05 at 01:34 -0300, Marcelo Ramos wrote:
[...]
> Well, it seems to be just a syntax error:
> 
> request.user.message_set.create(message=gettext("The %(verbose_name)s
> was created successfully." % {"verbose_name":
> model._meta.verbose_name}))
> 
> Remove the ) after successfully." and add it in the end of the line.
> 
> Isn't the correct syntax
> gettext(".. %(foo) .." % {'foo': 'bar'} )) instead of
> gettext(".. %(foo) ..") % {'foo': 'bar'} ) ?

No, it should be the second version. The reason is that you want to
translate the string with the format markers unsubstituted. That is, the
translators should see "this is a string with %(foo)s" and that is the
string gettext() will use to extract the translation from the message
catalog. Only after extracting the translation, will Python substitute
in the parameter values.

For some reason, the gettext call is not returning something with a
%(verbose_name)s in it. Why this is happening is still a mystery to me,
but I haven't had a chance to look at it too deeply yet.

Can you check the PO file for your locale and make sure there isn't some
silly translation error in that string. It should include
%(verbose_name)s in the translated string and nothing else?

> But another problem remains: the string is not being translated here.

That's expected, for the reasons mentioned above: with the parameters
substituted into the string, it is no longer an exact match for anything
in the translation catalog.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to