From: Ævar Arnfjörð Bjarmason Date: Mon, 30 Aug 2010 16:02:41 +0000 (+0000) Subject: gettext tests: test message re-encoding under Shell X-Git-Tag: ko-pu~10^2~140 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=14dcd54ede904e6102129805767fc03aed554ab7;p=git.git gettext tests: test message re-encoding under Shell Our PO files are written in UTF-8, but We're not using setlocale(LC_CTYPE, "") so it's not a given that someone with e.g. a ISO-8859-1 locale will get messages in ISO-8859-1, and not UTF-8. Introduce a new test to test for this, it uses the recently added GETTEXT_ISO_LOCALE prerequisite. This patch only tests the shellscript portion of our gettext interface. I can't get any of these tests to fail on any of the gettext implementations I have around, even without the previous patch to gettext.c. But having exhaustive tests in this area is good regardless. Signed-off-by: Ævar Arnfjörð Bjarmason --- diff --git a/po/is.po b/po/is.po index 440bbdfdf..e2c1414cf 100644 --- a/po/is.po +++ b/po/is.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Git\n" "Report-Msgid-Bugs-To: Git Mailing List \n" -"POT-Creation-Date: 2010-09-20 14:41+0000\n" +"POT-Creation-Date: 2010-09-20 14:43+0000\n" "PO-Revision-Date: 2010-06-05 19:06 +0000\n" "Last-Translator: Ævar Arnfjörð Bjarmason \n" "Language-Team: Git Mailing List \n" @@ -31,6 +31,18 @@ msgstr "TILRAUN: C tilraunastrengur" msgid "TEST: A C test string %s" msgstr "TILRAUN: C tilraunastrengur %s" +#. TRANSLATORS: This is a test. You don't need to translate it. +#: t/t0200/test.c:15 +#, c-format +msgid "TEST: Hello World!" +msgstr "TILRAUN: Halló Heimur!" + +#. TRANSLATORS: This is a test. You don't need to translate it. +#: t/t0200/test.c:18 +#, c-format +msgid "TEST: Old English Runes" +msgstr "TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ" + #. TRANSLATORS: This is a test. You don't need to translate it. #: t/t0200/test.sh:8 msgid "TEST: A Shell test string" diff --git a/t/t0200/test.c b/t/t0200/test.c index 93373b38f..82682dce1 100644 --- a/t/t0200/test.c +++ b/t/t0200/test.c @@ -10,4 +10,10 @@ int main(void) /* TRANSLATORS: This is a test. You don't need to translate it. */ printf(_("TEST: A C test string %s"), "variable"); + + /* TRANSLATORS: This is a test. You don't need to translate it. */ + printf(_("TEST: Hello World!")); + + /* TRANSLATORS: This is a test. You don't need to translate it. */ + printf(_("TEST: Old English Runes")); } diff --git a/t/t0204-gettext-reencode-sanity.sh b/t/t0204-gettext-reencode-sanity.sh new file mode 100755 index 000000000..3222e37cd --- /dev/null +++ b/t/t0204-gettext-reencode-sanity.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# +# Copyright (c) 2010 Ævar Arnfjörð Bjarmason +# + +test_description="Gettext reencoding of our *.po/*.mo files works" + +. ./lib-gettext.sh + + +test_expect_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Icelandic' ' + printf "TILRAUN: Halló Heimur!" >expect && + LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: Hello World!" >actual && + test_cmp expect actual +' + +test_expect_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Runes' ' + printf "TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ" >expect && + LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: Old English Runes" >actual && + test_cmp expect actual +' + +test_expect_success GETTEXT_ISO_LOCALE 'gettext: Emitting ISO-8859-1 from our UTF-8 *.mo files / Icelandic' ' + printf "TILRAUN: Halló Heimur!" | iconv -f UTF-8 -t ISO8859-1 >expect && + LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: Hello World!" >actual && + test_cmp expect actual +' + +test_expect_success GETTEXT_ISO_LOCALE 'gettext: Emitting ISO-8859-1 from our UTF-8 *.mo files / Runes' ' + LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: Old English Runes" >runes && + + if grep "^TEST: Old English Runes$" runes + then + say "Your system can not handle this complexity and returns the string as-is" + else + # Both Solaris and GNU libintl will return this stream of + # question marks, so it is s probably portable enough + printf "TILRAUN: ?? ???? ??? ?? ???? ?? ??? ????? ??????????? ??? ?? ????" >runes-expect && + test_cmp runes-expect runes + fi +' + +test_done