[Openstack] Nova now i18n-ified

Jay Pipes jaypipes at gmail.com
Wed Dec 22 16:57:01 UTC 2010


Use the second pattern.  It will be properly picked up for translation
by gettext.  So, in short, use dict-based formatting markers when this
situation arises.

Cheers!
jay

On Wed, Dec 22, 2010 at 11:30 AM, Ed Leafe <ed at leafe.com> wrote:
> On Dec 22, 2010, at 11:01 AM, Jay Pipes wrote:
>
>> When you have strings that have formatting markers in them (like %s),
>> LEAVE the formatting markers in place.
>
>        What about if there are strings with more than one formatting marker? Most localization routines will not allow positional formatting, and require you to use dict-based formatting. E.g.:
>
> _("This is a %s %s") % ("green", "house")
>
>        This will work fine in English, but in Spanish the order of the words in the localized string would be reversed. The most common solution is to use dict-based formatting:
>
> _("This is a %(color)s %(thing)s") % {"color": "green", "thing": "house"}
>
>        Do we have the facility for handling multiple substitutions in localized strings?
>
>
>
> -- Ed Leafe
>




More information about the Openstack mailing list