mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Final i18n unit test fixes.
This commit is contained in:
committed by
Rob Crittenden
parent
fc842e3650
commit
1eb3033311
@@ -191,10 +191,11 @@ maintainer-clean: distclean
|
|||||||
test_lang:
|
test_lang:
|
||||||
rm -rf test.po test_locale
|
rm -rf test.po test_locale
|
||||||
$(MSGINIT) --no-translator -i $(DOMAIN).pot -l en_US -o test.po
|
$(MSGINIT) --no-translator -i $(DOMAIN).pot -l en_US -o test.po
|
||||||
$(SED) -i -r -e 's/^msgstr[ \t]+"(.*)"[ \t]*$$/msgstr "\xe2\x86\x92\1\xe2\x86\x90"/' test.po
|
$(SED) -i -r -e 's/Language: en_US/Language: xh_ZA/' test.po
|
||||||
|
$(SED) -i -r -e 's/^msgstr[ \t]+"(..*)"[ \t]*$$/msgstr "\xe2\x86\x92\1\xe2\x86\x90"/' test.po
|
||||||
$(SED) -i -r -e 's/^msgstr[ \t]+"(.*)(\\n)(.)"[ \t]*$$/msgstr "\1\xe2\x86\x90\2"/' test.po
|
$(SED) -i -r -e 's/^msgstr[ \t]+"(.*)(\\n)(.)"[ \t]*$$/msgstr "\1\xe2\x86\x90\2"/' test.po
|
||||||
$(MKDIR_P) test_locale/en_US/LC_MESSAGES
|
$(MKDIR_P) test_locale/xh_ZA/LC_MESSAGES
|
||||||
$(MSGFMT) -o test_locale/en_US/LC_MESSAGES/ipa.mo test.po
|
$(MSGFMT) -o test_locale/xh_ZA/LC_MESSAGES/ipa.mo test.po
|
||||||
|
|
||||||
test: test_lang
|
test: test_lang
|
||||||
./test_i18n.py
|
./test_i18n.py
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import sys
|
|||||||
import gettext
|
import gettext
|
||||||
import locale
|
import locale
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
def get_msgid(po_file):
|
def get_msgid(po_file):
|
||||||
'Get the first non-empty msgid from the po file'
|
'Get the first non-empty msgid from the po file'
|
||||||
@@ -62,11 +63,11 @@ def main():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
# The test installs the test message catalog under the en_US (e.g. U.S. English)
|
# The test installs the test message catalog under the xh_ZA (e.g. Zambia Xhosa)
|
||||||
# language. It would be nice to use a dummy language not associated with any
|
# language. It would be nice to use a dummy language not associated with any
|
||||||
# real language, but the setlocale function demands the locale be a valid known
|
# real language, but the setlocale function demands the locale be a valid known
|
||||||
# locale, U.S. English is a reasonable choice.
|
# locale, Zambia Xhosa is a reasonable choice :)
|
||||||
locale.setlocale(locale.LC_MESSAGES, 'en_US.UTF-8')
|
os.environ['LANG'] = 'xh_ZA'
|
||||||
|
|
||||||
# Tell gettext that our domain is 'ipa', that locale_dir is 'test_locale'
|
# Tell gettext that our domain is 'ipa', that locale_dir is 'test_locale'
|
||||||
# (i.e. where to look for the message catalog) and that we want the translations
|
# (i.e. where to look for the message catalog) and that we want the translations
|
||||||
|
|||||||
@@ -183,10 +183,10 @@ class Plugin(ReadOnly):
|
|||||||
'%s.%s' % (b.__module__, b.__name__) for b in cls.__bases__
|
'%s.%s' % (b.__module__, b.__name__) for b in cls.__bases__
|
||||||
)
|
)
|
||||||
self.doc = _(cls.__doc__)
|
self.doc = _(cls.__doc__)
|
||||||
if self.doc is None:
|
if not self.doc.msg:
|
||||||
self.summary = '<%s>' % self.fullname
|
self.summary = '<%s>' % self.fullname
|
||||||
else:
|
else:
|
||||||
self.summary = unicode(self.doc).split('\n\n', 1)[0]
|
self.summary = unicode(self.doc).split('\n\n', 1)[0].strip()
|
||||||
log = logging.getLogger(self.fullname)
|
log = logging.getLogger(self.fullname)
|
||||||
for name in ('debug', 'info', 'warning', 'error', 'critical', 'exception'):
|
for name in ('debug', 'info', 'warning', 'error', 'critical', 'exception'):
|
||||||
if hasattr(self, name):
|
if hasattr(self, name):
|
||||||
|
|||||||
@@ -21,8 +21,10 @@
|
|||||||
Test the `ipalib.text` module.
|
Test the `ipalib.text` module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import nose
|
import nose
|
||||||
|
import locale
|
||||||
from tests.util import raises, assert_equal
|
from tests.util import raises, assert_equal
|
||||||
from ipalib.request import context
|
from ipalib.request import context
|
||||||
from ipalib import request
|
from ipalib import request
|
||||||
@@ -75,12 +77,8 @@ def test_gettext():
|
|||||||
localedir='install/po/test_locale'
|
localedir='install/po/test_locale'
|
||||||
test_file='install/po/test.po'
|
test_file='install/po/test.po'
|
||||||
|
|
||||||
# The test installs the test message catalog under the en_US
|
lang = os.environ['LANG']
|
||||||
# (e.g. U.S. English) language. It would be nice to use a dummy
|
os.environ['LANG'] = 'xh_ZA'
|
||||||
# language not associated with any real language, but the
|
|
||||||
# setlocale function demands the locale be a valid known locale,
|
|
||||||
# U.S. English is a reasonable choice.
|
|
||||||
# request.set_languages('en_US.UTF-8')
|
|
||||||
|
|
||||||
# Tell gettext that our domain is 'ipa', that locale_dir is
|
# Tell gettext that our domain is 'ipa', that locale_dir is
|
||||||
# 'test_locale' (i.e. where to look for the message catalog)
|
# 'test_locale' (i.e. where to look for the message catalog)
|
||||||
@@ -117,6 +115,8 @@ def test_gettext():
|
|||||||
|
|
||||||
# Reset the language and assure we don't get the test values
|
# Reset the language and assure we don't get the test values
|
||||||
context.__dict__.clear()
|
context.__dict__.clear()
|
||||||
|
os.environ['LANG'] = lang
|
||||||
|
|
||||||
translated = unicode(localized)
|
translated = unicode(localized)
|
||||||
|
|
||||||
assert(translated[0] != prefix)
|
assert(translated[0] != prefix)
|
||||||
|
|||||||
Reference in New Issue
Block a user