summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3c427f1)
raw | patch | inline | side by side (parent: 3c427f1)
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | |
Mon, 30 Aug 2010 16:02:41 +0000 (16:02 +0000) | ||
committer | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | |
Sat, 30 Oct 2010 07:10:07 +0000 (07:10 +0000) |
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 <avarab@gmail.com>
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 <avarab@gmail.com>
po/is.po | patch | blob | history | |
t/t0200/test.c | patch | blob | history | |
t/t0204-gettext-reencode-sanity.sh | [new file with mode: 0755] | patch | blob |
diff --git a/po/is.po b/po/is.po
index 440bbdfdfc9681777ce4ee63bfb2f63d049c2744..e2c1414cfffa61a357d582f17c1e4607a9898a77 100644 (file)
--- a/po/is.po
+++ b/po/is.po
msgstr ""
"Project-Id-Version: Git\n"
"Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\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 <avarab@gmail.com>\n"
"Language-Team: Git Mailing List <git@vger.kernel.org>\n"
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 93373b38f7f71682f405e7ae5e02726dfa2e8e64..82682dce1ce5099a46900ad27bfd9db63817474b 100644 (file)
--- a/t/t0200/test.c
+++ b/t/t0200/test.c
/* 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
--- /dev/null
@@ -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