From c161784973fdedb146a4087d8692b157214c4db0 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Sun, 4 Jan 2009 00:46:21 -0700 Subject: Added request.ugettext() and request.ungettext() functions; added corresponding unit tests --- ipalib/request.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'ipalib/request.py') diff --git a/ipalib/request.py b/ipalib/request.py index f5400b75..6ad7ad35 100644 --- a/ipalib/request.py +++ b/ipalib/request.py @@ -32,12 +32,20 @@ from constants import OVERRIDE_ERROR context = threading.local() -def _(message): - if hasattr(context, 'gettext'): - return context.gettext(message) +def ugettext(message): + if hasattr(context, 'ugettext'): + return context.ugettext(message) return message.decode('UTF-8') +def ungettext(singular, plural, n): + if hasattr(context, 'ungettext'): + return context.ungettext(singular, plural, n) + if n == 1: + return singular.decode('UTF-8') + return plural.decode('UTF-8') + + def set_languages(*languages): if hasattr(context, 'languages'): raise StandardError(OVERRIDE_ERROR % -- cgit