n00b question on spacing

Chris Angelico rosuav at gmail.com
Sat Jun 22 19:37:33 EDT 2013


On Sun, Jun 23, 2013 at 9:28 AM, Dave Angel <davea at davea.name> wrote:
> On 06/22/2013 07:12 PM, Chris Angelico wrote:
>>
>> On Sun, Jun 23, 2013 at 1:24 AM, Rick Johnson
>> <rantingrickjohnson at gmail.com> wrote:
>>>
>>>    _fmtstr = "Item wrote to MongoDB database {0}, {1}"
>>>    msg = _fmtstr.format(_arg1, _arg2)
>>
>>
>> As a general rule, I don't like separating format strings and their
>> arguments. That's one of the more annoying costs of i18n. Keep them in
>> a single expression if you possibly can.
>>
>
> On the contrary, i18n should be done with config files.  The format string
> is the key to the actual string which is located in the file/dict.
> Otherwise you're shipping separate source files for each language -- blecch.

The simplest way to translate is to localize the format string; that's
the point of .format()'s named argument system (since it lets you
localize in a way that reorders the placeholders). What that does is
it puts the format string away in a config file, while the replaceable
parts are here in the source. That's why I say that's a cost of i18n -
it's a penalty that has to be paid in order to move text strings away.

> The program that's intended to be internationalized is written using
> "programmereze" strings.  That's a strange inhuman language that's only
> approximately comprehensible by the developer and close associates. Then
> that gets translated into a bunch of language-specific config files, with
> English probably being one of them.

Heh. That's one way of looking at it... I don't really know what
language we speak; at what point is it deemed a separate dialect, and
at what point a unique language? Hmmm.

ChrisA



More information about the Python-list mailing list