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 <[email protected]> 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
>

_______________________________________________
Mailing list: https://launchpad.net/~openstack
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openstack
More help   : https://help.launchpad.net/ListHelp

Reply via email to