← Back to team overview

openstack team mailing list archive

Re: Nova now i18n-ified

 

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@xxxxxxxxx> 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
>



References