Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'argument': 0.05; 'string.': 0.05; 'puts': 0.07; 'source.': 0.07; 'string': 0.09; 'deemed': 0.09; 'executable': 0.09; 'msg': 0.09; 'preferable': 0.09; 'runtime': 0.09; 'separating': 0.09; 'string;': 0.09; 'strings.': 0.09; 'wrapper': 0.09; 'subject:question': 0.10; 'translate': 0.10; 'developer': 0.10; 'wrote': 0.14; 'language.': 0.14; '1.)': 0.16; '23,': 0.16; 'crude': 0.16; 'language?': 0.16; 'simplest': 0.16; 'files.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'trying': 0.19; 'file,': 0.19; 'translated': 0.19; 'written': 0.21; '>>>': 0.22; 'separate': 0.22; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'certainly': 0.24; 'config': 0.24; 'lets': 0.24; 'specifies': 0.24; 'string,': 0.24; 'file.': 0.24; '(or': 0.24; 'source': 0.25; 'equivalent': 0.26; 'handling': 0.26; 'possibly': 0.26; 'skip:_ 20': 0.27; 'values': 0.27; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'am,': 0.29; 'words': 0.29; 'needed.': 0.30; 'specified': 0.30; 'code': 0.31; '(since': 0.31; '>>>>': 0.31; 'away.': 0.31; 'bunch': 0.31; 'file': 0.32; 'probably': 0.32; 'text': 0.33; 'actual': 0.34; 'johnson': 0.35; 'usual': 0.35; 'but': 0.35; 'version': 0.36; 'located': 0.36; 'really': 0.36; 'c++': 0.36; 'done': 0.36; 'should': 0.36; 'being': 0.38; 'somebody': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'dave': 0.60; 'expression': 0.60; 'french': 0.61; "you're": 0.61; 'making': 0.63; 'costs': 0.63; 'real': 0.63; 'such': 0.63; 'more': 0.64; 'different': 0.65; 'here': 0.66; 'close': 0.67; 'received:74.208': 0.68; 'physical': 0.72; 'country': 0.77; 'dict,': 0.84; 'heh.': 0.84; 'penalty': 0.84; 'received:74.208.4.194': 0.84; 'angel': 0.91; 'rick': 0.93; '2013': 0.98 Date: Sat, 22 Jun 2013 19:56:21 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: n00b question on spacing References: <51C4D2FF.8000709@digipen.edu> <51870913-c348-4807-bc25-aa7c8fbf0001@googlegroups.com> <51C63334.2080805@davea.name> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:pwkpiZkSGVT0mcwX9UjjgfcPWxQIGtpnWPPpH2aK4BH WuXB3JP7GvAx1g/0+0fSka+XZFVvoQyIzlI7JvrcYDbDIkKBJM 1ubIRrhFxOfBkcIx5h/N8c5tQc4xMmg/vbLhcxoaFMU2YeXI5L ReCoE0ojKNqieegZYOaJQiVQQ+rBAIR3eRD3qA82fXPwDdbxp7 GZxnHsfVs7ucACoUilEAsoV5Vh78UEvDqtzTLHFQI1phPnfCZb ytOBbrR0/tIzLYgFZoA3s+lrVy438jbF2TX70oAQFGQ7owzhsq 04BOCx1jsWjGW7mHIsj1ShJcoNizHU1cytWit6aNEagaiJAr3T x+CIEDgtoVbRqPgbUBl8= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 72 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371945395 news.xs4all.nl 15880 [2001:888:2000:d::a6]:40234 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48955 On 06/22/2013 07:37 PM, Chris Angelico wrote: > On Sun, Jun 23, 2013 at 9:28 AM, Dave Angel wrote: >> On 06/22/2013 07:12 PM, Chris Angelico wrote: >>> >>> On Sun, Jun 23, 2013 at 1:24 AM, Rick Johnson >>> 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 **as specified in the physical program** >> 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. What I was trying to say is that the programmereze format string in the code is replaced at runtime by the French format string in the config file. > > 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. Certainly the reorderability of the format string is significant. Not only can it be reordered, but more than one instance of some of the values is permissible if needed. (What's missing is a decent handling of such things as singular/plural, where you want a different version per country of one (or a few) words from the format string, based on whether a value is exactly 1.) But the language is missing the indirection I described. So you have to use a (function or whatever) wrapper to look up the actual format string in the config file. My point is by making that file equivalent to a dict, you get to have an executable program in "programmereze" before creating any config files, but still able to handle any real language with one config file per language. This is much preferable to the usual numeric lookup, where somebody specifies the 17th format string to be used at this place in the code. Even when you use C++ names, they're still only a crude approximation to the real purpose of the string. > >> 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 > -- DaveA