diff options
author | John Dennis <jdennis@redhat.com> | 2012-03-26 22:26:35 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2012-04-10 18:11:48 -0400 |
commit | 689bea65757bae66b387acde3ffc7897e6b0ec3b (patch) | |
tree | ef8fde0ba8ef3d59a410a82cfa0d7790f5b19735 /install/po/Makefile.in | |
parent | b8f1292e869c3c0d2301809054eb21a72f02b180 (diff) | |
download | freeipa-689bea65757bae66b387acde3ffc7897e6b0ec3b.tar.gz freeipa-689bea65757bae66b387acde3ffc7897e6b0ec3b.tar.xz freeipa-689bea65757bae66b387acde3ffc7897e6b0ec3b.zip |
text unit test should validate using installed mo file
We use custom gettext classes (e.g. GettextFactory &
NGettextFactory). We should exercise those classes with an installed
binary mo file to demonstrate we are actually returning the expected
translated strings for all strings defined as being translatable.
The test logic in install/po/test_i18n.py was recently enhanced to
make this type of testing easier and more complete.
tests/test_ipalib/test_text.py should import the new i18n test support
and run it.
Previously tests/test_ipalib/test_text.py made a feeble but incomplete
attempt to do the above but even that was often not run because the
test would skip because the necessary test files were not available
unless they had been manually created in the install/po subdir. It is
now possible to correct those deficiencies in the test.
This patch does the following:
* Moves the location of i18n test code and adjust references to it.
install/po/test_i18n.py was moved to tests/i18n.py. This permits
tests/test_ipalib/test_text.py to import the i18n test utilities
in a clean fashion. The Makefile in install/po now calls this
same file.
* Modfies test function in test_i18n.py to accept function pointers
for retreiving a translation.
* Imports test_i18n.py from the install/po directory in the tree
* Creates a tmp directory for the test localedir
* Parses the current ipa.pot file in install/po and generates
a test po and mo file with special unicode markers. It installs
the test mo file in the tmp localedir. This is accomplished by
calling create_po() from the test_i18n.py file.
* If any of the above does not work it raises nose.SkipTest with
the reason, and skips the test.
* It sets up functions to get a translation and a plural translation
via our text.GettextFactory class and text.NGettextFactory class
respectively. This are the functions we use intenally to get
translations. It set the localdir and lang which are used by those
classes to match our test configuration. It then runs a validation
test on every translation and it's plural found in the test.po file
by calling po_file_iterate and passed it the function pointers to
our internal routines.
* At the conclusion of the test it cleans up after itself.
Note: extraneous files are not created in the tree, only a tmp
directory is utilized.
Validating msgid's in C code was insufficient.
* Make the discovery of format conversions much more robust by authoring
a new function parse_printf_fmt() that is able to discover each
format conversion in a string and break it into it's individual
subparts. One of those subparts is the argument selector index. In c
code we need to know if the argumenet selector index is present to
know if translator can reorder the substitution strings.
This replaces the simplistic python_anonymous_substitutions_regexp
which was insufficient to deal with other programming languages
(e.g. c).
* Add get_prog_langs() function to return the set of programming
languages a msgid appears in. This is necessar because the msdid
validation is programming language specific.
https://fedorahosted.org/freeipa/ticket/2582
Diffstat (limited to 'install/po/Makefile.in')
-rw-r--r-- | install/po/Makefile.in | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/install/po/Makefile.in b/install/po/Makefile.in index 4bee861a..d65ba0c7 100644 --- a/install/po/Makefile.in +++ b/install/po/Makefile.in @@ -15,6 +15,7 @@ MSGINIT = @MSGINIT@ MSGMERGE = @MSGMERGE@ MSGCMP = @MSGCMP@ TX = @TX@ +IPA_TEST_I18N = ../../tests/i18n.py DOMAIN = @GETTEXT_DOMAIN@ MSGMERGE_UPDATE = $(MSGMERGE) --update @@ -129,7 +130,7 @@ update-pot: echo "$(DOMAIN).pot unmodified" ; \ fi || : @rm -f $(DOMAIN).pot.update $(DOMAIN).pot.update.tmp $(DOMAIN).pot.tmp - ./test_i18n.py --show-strings --validate-pot $(DOMAIN).pot + $(IPA_TEST_I18N) --show-strings --validate-pot $(DOMAIN).pot msg-stats: @pot_count=`$(MSGFMT) --statistics $(DOMAIN).pot 2>&1 | \ @@ -169,38 +170,14 @@ distclean: clean maintainer-clean: distclean -# We test our translations by taking the original untranslated string -# (e.g. msgid) and prepend a prefix character and then append a suffix -# character. The test consists of asserting that the first character in the -# translated string is the prefix, the last character in the translated string -# is the suffix and the everything between the first and last character exactly -# matches the original msgid. -# -# We use unicode characters not in the ascii character set for the prefix and -# suffix to enhance the test. To make reading the translated string easier the -# prefix is the unicode right pointing arrow and the suffix left pointing arrow, -# thus the translated string looks like the original string enclosed in -# arrows. In ASCII art the string "foo" would render as: -# -->foo<-- -# -# Unicode right pointing arrow: u'\u2192', utf-8 = '\xe2\x86\x92' -# Unicode left pointing arrow: u'\u2190', utf-8 = '\xe2\x86\x90' -# -# The sed command below performs the prefix and suffix substitution. -# -# When msginit is invoked with an English target locale it copies the msgid -# into the msgstr. This is an undocumented feature of msginit. Otherwise the -# msgstr will be set to the empty string (i.e. untranslated). We depend on -# the msgid being copied to the msgstr. - test: - ./test_i18n.py --test-gettext + $(IPA_TEST_I18N) --test-gettext validate-pot: - ./test_i18n.py --show-strings --validate-pot $(DOMAIN).pot + $(IPA_TEST_I18N) --show-strings --validate-pot $(DOMAIN).pot validate-po: - ./test_i18n.py --show-strings --validate-po $(po_files) + $(IPA_TEST_I18N) --show-strings --validate-po $(po_files) debug: @echo Python potfiles: |