mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-09-03 20:52:56 -05:00
Added request.ugettext() and request.ungettext() functions; added corresponding unit tests
This commit is contained in:
+11
-3
@@ -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 %
|
||||
|
||||
Reference in New Issue
Block a user