From d32dbb5d3362b63917d7e3f7002cad67d9e6693b Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 21 May 2011 15:10:13 +0200 Subject: [PATCH] Enhance translation code to support plural translations. --- pakfire/i18n.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pakfire/i18n.py b/pakfire/i18n.py index 1ea45f890..dbcb8ca13 100644 --- a/pakfire/i18n.py +++ b/pakfire/i18n.py @@ -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) -- 2.39.5