[Idle-dev] I18N prep work - convert strings to use format()

Al Sweigart al at inventwithpython.com
Wed Jan 21 09:03:41 CET 2015


I'd like to change the old-style string formatting from '%s %s' %
(foo, bar) to the format() string method version. This is not just a
cosmetic change, but would be part of the prep work for I18N support
for IDLE.

For some languages, the order that variables would need to be
interpolated into strings would not be the same. For example, in
English you could have:

color = 'black'
animal = 'cat'
"The %s %s's toy." % (color, animal)

While in Spanish, this would be:

color = 'negro'
animal = 'gato'
"El juguete del %s %s." % (animal, color)

However, this defeats translating the "The %s %s's toy." string for
I18N. Using the format() string method fixes this: "The {color}
{animal}'s toy." could be translated as "El juguete del {animal}
{color}."

I'd like to go through the strings in IDLE and convert them to use
format(). This wouldn't be all of the strings: only those that are
user-facing and have multiple %s (or other) conversion specifiers
would need to be translated.

This is a change that touches on a lot of files, so I wanted to see if
anyone could foresee issues with this change before I start on it.

-Al


More information about the IDLE-dev mailing list