conditional expressions

Jeff Epler jepler at unpythonic.net
Mon Sep 30 14:34:04 EDT 2002


On Mon, Sep 30, 2002 at 03:09:08PM +0000, Alex Martelli wrote:
> I've shown this i18n'd with gettext's convention _( ... ) , but
> of course not all languages can pluralize by a constant suffix
> (English can't -- if ever a number of leaves or fishes was
> among the found things, we'd be in trouble...!-), so a better
> approach might be, e.g., for English:
[...]

It's even worse than this.  For instance, a language where the form for
1 is unique, numbers ending with 2, 3, 4 (except for 12, 13, and 14 --
I'm not sure about 111, 1211, etc) get a second form, and the rest of
the numbers get a third form.  I quote from the gnu gettext manual:

 Additional functions for plural forms
 -------------------------------------

    The functions of the `gettext' family described so far (and all the
 `catgets' functions as well) have one problem in the real world which
 have been neglected completely in all existing approaches.  What is
 meant here is the handling of plural forms.

    Looking through Unix source code before the time anybody thought
 about internationalization (and, sadly, even afterwards) one can often
 find code similar to the following:

         printf ("%d file%s deleted", n, n == 1 ? "" : "s");

 After the first complaints from people internationalizing the code
 people either completely avoided formulations like this or used
 strings like `"file(s)"'.  Both look unnatural and should be avoided.
 First tries to solve the problem correctly looked like this:

         if (n == 1)
           printf ("%d file deleted", n);
         else
           printf ("%d files deleted", n);

    But this does not solve the problem.  It helps languages where the
 plural form of a noun is not simply constructed by adding an `s'
 but that is all.  Once again people fell into the trap of believing
 the rules their language is using are universal.  But the handling
 of plural forms differs widely between the language families.
 For example, Rafal Maszkowski `<rzm at mat.uni.torun.pl>' reports:

      In Polish we use e.g. plik (file) this way:
           1 plik
           2,3,4 pliki
           5-21 pliko'w
           22-24 pliki
           25-31 pliko'w
      and so on (o' means 8859-2 oacute which should be rather okreska,
      similar to aogonek).
[.... about 250 more lines describing how gettext attempts to address
these situations]




More information about the Python-list mailing list