Proposed PEP for a Conditional Expression

Alex Martelli aleaxit at
Tue Sep 11 10:47:37 CEST 2001

"Christian Tanzer" <tanzer at> writes:
> print "%(plur_verb number 'Found') %(plur_noun number 'error')s" % neater
> with the parser in __getitem__ looking for spaces and using
> them, if found, to recognize formatting keywords such as
> 'plur_verb' -- makes for easier parsing AND for vastly easier
> i18n of messages (neater itself would of course use gettext
> as needed on the meaning-carrying words such as 'error' or
> 'Found':-).

Well, I'd use the contents of the interpolated string as key to get 
the translation (via gettext or otherwise). After all, different
languages might have totally different rules how to adapt a sentence
to the context supplied by `neater`.
In my experience that doesn't work well when the messages
include numbers that can vary all over the place, like,
here, the number of errors -- the i18n db gets overwhelmed
by almost-identical messages.  Yes, working by fragments
isn't quite as satisfactory -- here, I'm forcing the
verb to come before the direct object, for example, and
that might not be ideal for some languages -- that would
need some extra tricks.


More information about the Python-list mailing list