[Solved]-Django translations and gettext: The deprecation of the % (string interpolation) operator



You could use it safely. For example


The translation program xgettext, which is used by Django, does not care about the content to be translated. It just searches .py file for keywords such as ugettext_lazy or _ to collect the translatable strings(refs the manual of xgettext and Django code)

Furthermore, the .format() method above is a wrapper provided by the proxy object, like:

>>> ugettext_lazy(u'{foo}').format
<bound method __proxy__.__wrapper__ of <django.utils.functional.__proxy__ object at 0x102f19050>>

The invoking of the above .format() would get u'{foo}' to be translated to some unicode value, then call value.format with actual arguments. You could see that the translation and value.format happen in different stages.


Leave a comment