On Wed, Jan 21, 2015 at 10:03 AM, Al Sweigart <a...@inventwithpython.com> wrote: > > 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
Hi Al, If i18n is your goal, are you sure that string.format() is the way to go? string.format()'s syntax was not defined with this use-case in mind. For example, it supports a lot of things which are not relevant for translation, which would leave a lot of room for user errors of the sort that use valid string.format() syntax but produce unwanted results. A more significant drawback is that learning the syntax is unnecessarily difficult for someone who'd just want to make a translation. If i18n is the goal, I strongly suggest using a tool that was made for the purpose. - Tal Einat _______________________________________________ IDLE-dev mailing list IDLE-dev@python.org https://mail.python.org/mailman/listinfo/idle-dev