diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2009-01-03 22:03:37 -0700 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2009-01-03 22:03:37 -0700 |
commit | c081ce5460018634fb30249ead2168ebf3a79044 (patch) | |
tree | 79f6de9b1a9c96863e71165b68bfda4d32334185 | |
parent | 912ab9e68b6030d4d115d3683893477abb4f6451 (diff) | |
download | freeipa-c081ce5460018634fb30249ead2168ebf3a79044.tar.gz freeipa-c081ce5460018634fb30249ead2168ebf3a79044.tar.xz freeipa-c081ce5460018634fb30249ead2168ebf3a79044.zip |
request.create_translation() now sets context.ugettext and context.ungettext
-rw-r--r-- | ipalib/request.py | 6 | ||||
-rw-r--r-- | tests/test_ipalib/test_request.py | 26 |
2 files changed, 16 insertions, 16 deletions
diff --git a/ipalib/request.py b/ipalib/request.py index 5a07d4dbb..f5400b75c 100644 --- a/ipalib/request.py +++ b/ipalib/request.py @@ -50,7 +50,7 @@ def set_languages(*languages): def create_translation(domain, localedir, *languages): - if hasattr(context, 'gettext') or hasattr(context, 'ngettext'): + if hasattr(context, 'ugettext') or hasattr(context, 'ungettext'): raise StandardError( 'create_translation() already called in thread %r' % threading.currentThread().getName() @@ -59,5 +59,5 @@ def create_translation(domain, localedir, *languages): translation = gettext.translation(domain, localedir=localedir, languages=context.languages, fallback=True ) - context.gettext = translation.ugettext - context.ngettext = translation.ungettext + context.ugettext = translation.ugettext + context.ungettext = translation.ungettext diff --git a/tests/test_ipalib/test_request.py b/tests/test_ipalib/test_request.py index 5efc0abdb..7096b9274 100644 --- a/tests/test_ipalib/test_request.py +++ b/tests/test_ipalib/test_request.py @@ -65,9 +65,9 @@ def test_create_translation(): c = request.context t = TempDir() - # Test that StandardError is raised if gettext or ngettext: - assert not (hasattr(c, 'gettext') or hasattr(c, 'ngettext')) - for name in 'gettext', 'ngettext': + # Test that StandardError is raised if ugettext or ungettext: + assert not (hasattr(c, 'ugettext') or hasattr(c, 'ungettext')) + for name in ('ugettext', 'ungettext'): setattr(c, name, None) e = raises(StandardError, f, 'ipa', None) assert str(e) == ( @@ -77,23 +77,23 @@ def test_create_translation(): delattr(c, name) # Test using default language: - assert not hasattr(c, 'gettext') - assert not hasattr(c, 'ngettext') + assert not hasattr(c, 'ugettext') + assert not hasattr(c, 'ungettext') assert not hasattr(c, 'languages') f('ipa', t.path) - assert hasattr(c, 'gettext') - assert hasattr(c, 'ngettext') + assert hasattr(c, 'ugettext') + assert hasattr(c, 'ungettext') assert c.languages == locale.getdefaultlocale()[:1] - del c.gettext - del c.ngettext + del c.ugettext + del c.ungettext del c.languages # Test using explicit languages: langs = ('de', 'es') f('ipa', t.path, *langs) - assert hasattr(c, 'gettext') - assert hasattr(c, 'ngettext') + assert hasattr(c, 'ugettext') + assert hasattr(c, 'ungettext') assert c.languages == langs - del c.gettext - del c.ngettext + del c.ugettext + del c.ungettext del c.languages |