[yum-commits] Branch 'yum-3_2_X' - yum/__init__.py yum/i18n.py
James Antill
james at osuosl.org
Fri Mar 6 21:50:10 UTC 2009
yum/__init__.py | 1 +
yum/i18n.py | 14 +++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
New commits:
commit 1cfe9fe917605ca680e3d7e72c6dff6bd59a9778
Author: Milos Komarcevic <miloskomarcevic at netscape.net>
Date: Fri Mar 6 14:51:54 2009 -0500
Add infrastructure for N_() aka. ngettext, no msgs changed
diff --git a/yum/__init__.py b/yum/__init__.py
index 3b9de26..54a0214 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -34,6 +34,7 @@ import gzip
import yum.i18n
_ = yum.i18n._
+P_ = yum.i18n.P_
try:
from iniparse.compat import ParsingError, ConfigParser
diff --git a/yum/i18n.py b/yum/i18n.py
index 50d0bd3..1a3d204 100755
--- a/yum/i18n.py
+++ b/yum/i18n.py
@@ -20,6 +20,16 @@ def dummy_wrapper(str):
'''
return to_unicode(str)
+def dummyP_wrapper(str1, str2, n):
+ '''
+ Dummy Plural Translation wrapper, just returning the singular or plural
+ string.
+ '''
+ if n == 1:
+ return str1
+ else:
+ return str2
+
# This is ported from ustr_utf8_* which I got from:
# http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
# I've tried to leave it close to the original C (same names etc.) so that
@@ -417,19 +427,21 @@ def to_str(obj):
try:
'''
- Setup the yum translation domain and make _() translation wrapper
+ Setup the yum translation domain and make _() and P_() translation wrappers
available.
using ugettext to make sure translated strings are in Unicode.
'''
import gettext
t = gettext.translation('yum', fallback=True)
_ = t.ugettext
+ P_ = t.nugettext
except:
'''
Something went wrong so we make a dummy _() wrapper there is just
returning the same text
'''
_ = dummy_wrapper
+ P_ = dummyP_wrapper
if __name__ == "__main__":
import sys
More information about the Yum-commits
mailing list