Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'argument': 0.05; 'puts': 0.07; 'source.': 0.07; 'string': 0.09; 'msg': 0.09; 'runtime': 0.09; 'separating': 0.09; 'string;': 0.09; 'subject:question': 0.10; 'translate': 0.10; 'wrote': 0.14; '1.)': 0.16; '23,': 0.16; 'enough.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'simplest': 0.16; 'singular': 0.16; 'surprising': 0.16; 'files.': 0.16; ':-)': 0.16; 'language': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'file,': 0.19; '>>>': 0.22; 'separate': 0.22; 'header:User-Agent:1': 0.23; 'certainly': 0.24; 'config': 0.24; 'lets': 0.24; 'string,': 0.24; 'file.': 0.24; '(or': 0.24; 'source': 0.25; 'handling': 0.26; 'possibly': 0.26; 'skip:_ 20': 0.27; 'values': 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; 'languages': 0.32; 'text': 0.33; 'actual': 0.34; 'johnson': 0.35; 'received:84': 0.35; 'but': 0.35; 'version': 0.36; 'located': 0.36; 'done': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'dave': 0.60; 'expression': 0.60; 'french': 0.61; 'numbers': 0.61; "you're": 0.61; 'costs': 0.63; 'such': 0.63; 'more': 0.64; 'different': 0.65; 'here': 0.66; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'physical': 0.72; 'country': 0.77; 'ending': 0.78; 'penalty': 0.84; 'reply-to:addr:python.org': 0.84; 'angel': 0.91; 'rick': 0.93; '2013': 0.98 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=RZapVTdv c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=oyR3mlnJdzkA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=NoHnAnvzSNwA:10 a=pGLkceISAAAA:8 a=fycJU_mwwew3XMqQY6AA:9 a=wPNLvfGTeEIA:10 a=MSl-tDqOz04A:10 X-AUTH: mrabarnett:2500 Date: Sun, 23 Jun 2013 02:20:56 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130509 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> <51C639A5.5070600@davea.name> In-Reply-To: <51C639A5.5070600@davea.name> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org 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: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371950455 news.xs4all.nl 15864 [2001:888:2000:d::a6]:59286 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48961 On 23/06/2013 00:56, Dave Angel wrote: > 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.) > [snip] One vs not-one isn't good enough. Some languages use the singular with any numbers ending in '1'. Some languages have singular, dual, and plural. Etc. It's surprising how inventive people can be! :-)