Final i18n unit test fixes.

This commit is contained in:
Pavel Zuna
2011-02-23 16:40:17 -05:00
committed by Rob Crittenden
parent fc842e3650
commit 1eb3033311
4 changed files with 16 additions and 14 deletions

View File

@@ -191,10 +191,11 @@ maintainer-clean: distclean
test_lang:
rm -rf test.po test_locale
$(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
$(MKDIR_P) test_locale/en_US/LC_MESSAGES
$(MSGFMT) -o test_locale/en_US/LC_MESSAGES/ipa.mo test.po
$(MKDIR_P) test_locale/xh_ZA/LC_MESSAGES
$(MSGFMT) -o test_locale/xh_ZA/LC_MESSAGES/ipa.mo test.po
test: test_lang
./test_i18n.py

View File

@@ -23,6 +23,7 @@ import sys
import gettext
import locale
import re
import os
def get_msgid(po_file):
'Get the first non-empty msgid from the po file'
@@ -62,11 +63,11 @@ def main():
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
# real language, but the setlocale function demands the locale be a valid known
# locale, U.S. English is a reasonable choice.
locale.setlocale(locale.LC_MESSAGES, 'en_US.UTF-8')
# locale, Zambia Xhosa is a reasonable choice :)
os.environ['LANG'] = 'xh_ZA'
# 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