Message102778
The full example:
===
import gettext
gettext.bindtextdomain("pygettext_test","./locale")
gettext.textdomain("pygettext_test")
_=gettext.gettext
n_=gettext.ngettext
n1=1
n2=3
print n_("there is %i command","there are %i commands",n1) % n1
print n_("there is %i command","there are %i commands",n2) % n2
===
the result of n_("there is %i command","there are %i commands",n2) will be:
"there is %i command"
or
"there are %i commands"
or
different string from translation file in case of other language then English as in Arabic we have 6 forms, 3 of them don't include %i.
"لا يوجد أي أمر"
"يوجد أمر واحد"
"يوجد أمران"
"يوجد %i أوامر"
"يوجد %i أمرا"
"يوجد %i أمر"
(You may not see the Arabic well aligned because it's a RTL language).
So format string is open to fit all languages.
That's why mapping good only for predefined strings.
Then these will be our solution:
===
print n_("there is {0} command","there are {0} commands",n1).format(n1)
print n_("there is {0} command","there are {0} commands",n2).format(n2)
=== |
|
Date |
User |
Action |
Args |
2010-04-10 13:26:37 | sneetsher | set | recipients:
+ sneetsher, georg.brandl, eric.smith |
2010-04-10 13:26:37 | sneetsher | set | messageid: <1270905997.55.0.741406429122.issue8359@psf.upfronthosting.co.za> |
2010-04-10 13:26:35 | sneetsher | link | issue8359 messages |
2010-04-10 13:26:35 | sneetsher | create | |
|