[ python-Bugs-949832 ] Problem w/6.27.2.2 GNUTranslations ungettext() example code

SourceForge.net noreply at sourceforge.net
Fri May 7 08:44:35 EDT 2004


Bugs item #949832, was opened at 2004-05-07 05:44
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=949832&group_id=5470

Category: Documentation
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Martin Miller (mrmiller)
Assigned to: Nobody/Anonymous (nobody)
Summary: Problem w/6.27.2.2 GNUTranslations ungettext() example code

Initial Comment:
> Here is an example: 
> 
> n = len(os.listdir('.'))
> cat = GNUTranslations(somefile)
> message = cat.ungettext(
>     'There is %(num)d file in this directory',
>     'There are %(num)d files in this directory',
>     n) % {'n': n}

The last line of code in the example should be:

>     n) % {'num': n}

Also, I don't think the example illustrates a realistic
usage of the ungettext() method, as it is unlikely that
the message catalog is going to have different message
id's for all the possible variations of the string each
with a different number of files in them -- exactly the
problem that ungettext() is suppose to address.

A better example would just use ungettext() to pick
either the word "file" or "files" based on the value of
n. It would be more realistic and the example code
would probably be simpler.





----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=949832&group_id=5470



More information about the Python-bugs-list mailing list