diff options
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/errors.py | 2 | ||||
-rw-r--r-- | ipalib/parameters.py | 2 | ||||
-rw-r--r-- | ipalib/request.py | 40 |
3 files changed, 2 insertions, 42 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py index 6883cbdab..e1d85c75d 100644 --- a/ipalib/errors.py +++ b/ipalib/errors.py @@ -101,7 +101,7 @@ current block assignments: """ from inspect import isclass -from request import ugettext, ungettext +from text import _ as ugettext, ngettext as ungettext from constants import TYPE_ERROR diff --git a/ipalib/parameters.py b/ipalib/parameters.py index 164374e00..daec1d6a9 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -102,7 +102,7 @@ a more detailed description for clarity. import re from types import NoneType from util import make_repr -from request import ugettext +from text import _ as ugettext from plugable import ReadOnly, lock, check_name from errors import ConversionError, RequirementError, ValidationError from errors import PasswordMismatch diff --git a/ipalib/request.py b/ipalib/request.py index 9a11fb9c3..15b26f598 100644 --- a/ipalib/request.py +++ b/ipalib/request.py @@ -23,8 +23,6 @@ Per-request thread-local data. """ import threading -import locale -import gettext from base import ReadOnly, lock from constants import OVERRIDE_ERROR, CALLABLE_ERROR @@ -58,41 +56,3 @@ def destroy_context(): value.disconnect() context.__dict__.clear() - -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 % - ('context', 'languages', context.languages, languages) - ) - if len(languages) == 0: - languages = locale.getdefaultlocale()[:1] - context.languages = languages - assert type(context.languages) is tuple - - -def create_translation(domain, localedir, *languages): - if hasattr(context, 'ugettext') or hasattr(context, 'ungettext'): - raise StandardError( - 'create_translation() already called in thread %r' % - threading.currentThread().getName() - ) - set_languages(*languages) - translation = gettext.translation(domain, - localedir=localedir, languages=context.languages, fallback=True - ) - context.ugettext = translation.ugettext - context.ungettext = translation.ungettext |