From 15012b7ecc4c304edeadda8c53836985ecee98e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Mon, 30 Aug 2010 16:59:13 +0000 Subject: [PATCH] gettext tests: test re-encoding with a UTF-8 msgid under Shell MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit A test that tests that calling gettext on a UTF-8 msgid works, and that recoding the resulting string works too. This test uses the --from-code=UTF-8 xgettext(1) argument introduced in an earlier patch. 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 --- po/is.po | 8 +++++++- t/t0200/test.c | 3 +++ t/t0204-gettext-reencode-sanity.sh | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/po/is.po b/po/is.po index e2c1414cf..815286beb 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:43+0000\n" +"POT-Creation-Date: 2010-09-20 14:44+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" @@ -43,6 +43,12 @@ msgstr "TILRAUN: Halló Heimur!" msgid "TEST: Old English Runes" msgstr "TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ" +#. TRANSLATORS: This is a test. You don't need to translate it. +#: t/t0200/test.c:21 +#, c-format +msgid "TEST: ‘single’ and “double” quotes" +msgstr "TILRAUN: ‚einfaldar‘ og „tvöfaldar“ gæsalappir" + #. 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 82682dce1..ff15c2f91 100644 --- a/t/t0200/test.c +++ b/t/t0200/test.c @@ -16,4 +16,7 @@ int main(void) /* TRANSLATORS: This is a test. You don't need to translate it. */ printf(_("TEST: Old English Runes")); + + /* TRANSLATORS: This is a test. You don't need to translate it. */ + printf(_("TEST: ‘single’ and “double” quotes")); } diff --git a/t/t0204-gettext-reencode-sanity.sh b/t/t0204-gettext-reencode-sanity.sh index 3222e37cd..1a7ea37e8 100755 --- a/t/t0204-gettext-reencode-sanity.sh +++ b/t/t0204-gettext-reencode-sanity.sh @@ -40,4 +40,25 @@ test_expect_success GETTEXT_ISO_LOCALE 'gettext: Emitting ISO-8859-1 from our UT fi ' +test_expect_success GETTEXT_LOCALE 'gettext: Fetching a UTF-8 msgid -> UTF-8' ' + printf "TILRAUN: ‚einfaldar‘ og „tvöfaldar“ gæsalappir" >expect && + LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: ‘single’ and “double” quotes" >actual && + test_cmp expect actual +' + +# How these quotes get transliterated depends on the gettext implementation: +# +# Debian: ,einfaldar' og ,,tvöfaldar" [GNU libintl] +# FreeBSD: `einfaldar` og "tvöfaldar" [GNU libintl] +# Solaris: ?einfaldar? og ?tvöfaldar? [Solaris libintl] +# +# Just make sure the contents are transliterated, and don't use grep -q +# so that these differences are emitted under --verbose for curious +# eyes. +test_expect_success GETTEXT_ISO_LOCALE 'gettext: Fetching a UTF-8 msgid -> ISO-8859-1' ' + LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: ‘single’ and “double” quotes" >actual && + grep "einfaldar" actual && + grep "$(echo tvöfaldar | iconv -f UTF-8 -t ISO8859-1)" actual +' + test_done -- 2.30.2