]> git.ipfire.org Git - pakfire.git/commitdiff
Enhance translation code to support plural translations.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 May 2011 13:10:13 +0000 (15:10 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 May 2011 13:10:13 +0000 (15:10 +0200)
pakfire/i18n.py

index 1ea45f890892b3b25d1cee679353395f334a31fc..dbcb8ca132229d7111439af557b942f4a00b4110 100644 (file)
@@ -11,14 +11,14 @@ import  gettext
 """
 N_ = lambda x: x
 
+def _(singular, plural=None, n=None):
+       """
+               A function that returnes the translation of a string if available.
 
-"""
-       A function that returnes the translation of a string if available.
-
-       The language is taken from the system environment.
-"""
-# Enable this to have translation in the development environment.
-# gettext.bindtextdomain("pakfire", "build/mo")
-
-_ = lambda x: gettext.ldgettext("pakfire", x)
+               The language is taken from the system environment.
+       """
+       if not plural is None:
+               assert n is not None
+               return gettext.ldngettext("pakfire", singular, plural, n)
 
+       return gettext.ldgettext("pakfire", singular)