On Tue, 2007-06-12 at 04:32 -0700, Eugene Morozov wrote:
> Hello,
> What is the correct way to use gettext_lazy with string interpolation?
> Aren't there built-in facilities for this in the Django?
Just using it normally -- using a gettext_lazy proxy object wherever you
would normally use a format string -- will do what you expect.
s = gettext_lazy('my string %s %d')
...
print s % ('fred', 11)
The only thing to consider is to make sure that you don't actually do
the interpolation too early -- since that converts it from a proxy to a
string -- so the translation has to take place at that moment. All this
means is don't do interpolation at import time, for example. Doing it
inside views or anything called from a view should be fine, though,
since the correct locale will already be in effect.
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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---