Added request.ugettext() and request.ungettext() functions; added corresponding unit tests

This commit is contained in:
Jason Gerard DeRose
2009-01-04 00:46:21 -07:00
parent c081ce5460
commit c161784973
4 changed files with 115 additions and 6 deletions
+11 -3
View File
@@ -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 %