diff options
Diffstat (limited to 'gettext-tools')
-rwxr-xr-x | gettext-tools/tests/xgettext-csharp-1 | 66 | ||||
-rwxr-xr-x | gettext-tools/tests/xgettext-csharp-2 | 86 | ||||
-rwxr-xr-x | gettext-tools/tests/xgettext-csharp-3 | 178 | ||||
-rwxr-xr-x | gettext-tools/tests/xgettext-csharp-4 | 42 | ||||
-rwxr-xr-x | gettext-tools/tests/xgettext-csharp-5 | 53 |
5 files changed, 425 insertions, 0 deletions
diff --git a/gettext-tools/tests/xgettext-csharp-1 b/gettext-tools/tests/xgettext-csharp-1 new file mode 100755 index 0000000..84b5d96 --- /dev/null +++ b/gettext-tools/tests/xgettext-csharp-1 @@ -0,0 +1,66 @@ +#!/bin/sh + +# Some tests for C# support + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles xg-cs-1.cs" +cat <<EOF > xg-cs-1.cs +using GNU.Gettext; +class TestCase { + public TestCase() { + GettextResourceManager rm = new GettextResourceManager("test"); + // standard usage + String test1 = rm.GetString("Test String 1"); + /* C style comment */ + String test2 = rm.GetString("Test String 2"); + // C# "multiline" string + String test3 = rm.GetString("Test " + + "String " + + "3"); + // empty string + String test4 = rm.GetString(""); +#if false + // commented out through #if + String test5 = rm.GetString("Test String 5"); +#endif + } +} +EOF + +tmpfiles="$tmpfiles xg-cs-1.po" +: ${XGETTEXT=xgettext} +${XGETTEXT} --omit-header --no-location -c -d xg-cs-1 xg-cs-1.cs +test $? = 0 || { rm -fr $tmpfiles; exit 1; } + +tmpfiles="$tmpfiles xg-cs-1.ok" +cat <<EOF > xg-cs-1.ok +#. standard usage +msgid "Test String 1" +msgstr "" + +#. C style comment +msgid "Test String 2" +msgstr "" + +#. C# "multiline" string +msgid "Test String 3" +msgstr "" + +#. empty string +msgid "" +msgstr "" + +#. commented out through #if +msgid "Test String 5" +msgstr "" +EOF + +: ${DIFF=diff} +${DIFF} xg-cs-1.ok xg-cs-1.po +result=$? + +rm -fr $tmpfiles + +exit $result diff --git a/gettext-tools/tests/xgettext-csharp-2 b/gettext-tools/tests/xgettext-csharp-2 new file mode 100755 index 0000000..b0b6e5a --- /dev/null +++ b/gettext-tools/tests/xgettext-csharp-2 @@ -0,0 +1,86 @@ +#!/bin/sh + +# More tests for C# support: UTF-8 encoded source files + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles xg-cs-2.cs" +cat <<\EOF > xg-cs-2.cs +class TestCase { + public static void Main (String[] args) { + Console.WriteLine(GetString("Russian (Русский): Здравствуйте")); + Console.WriteLine(GetString("Vietnamese (Tiếng Việt): Chào bạn")); + Console.WriteLine(GetString("Japanese (日本語): こんにちは")); + Console.WriteLine(GetString("Thai (ภาษาไทย): สวัสดีครับ")); + Console.WriteLine(GetString("Script: 𝒞")); + Console.WriteLine(GetString("Russian (\u0420\u0443\u0441\u0441\u043a\u0438\u0439): \u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435")); + Console.WriteLine(GetString("Vietnamese (Ti\u1ebfng Vi\u1ec7t): Ch\u00e0o b\u1ea1n")); + Console.WriteLine(GetString("Japanese (\u65e5\u672c\u8a9e): \u3053\u3093\u306b\u3061\u306f")); + Console.WriteLine(GetString("Thai (\u0e20\u0e32\u0e29\u0e32\u0e44\u0e17\u0e22): \u0e2a\u0e27\u0e31\u0e2a\u0e14\u0e35\u0e04\u0e23\u0e31\u0e1a")); + Console.WriteLine(GetString("Script: \U0001d49e")); + // And now a comment with Русский and 日本語 and Unicode escapes: B\u00f6se B\u00fcbchen + Console.WriteLine(GetString("This string has a multilingual comment")); + } +} +EOF + +tmpfiles="$tmpfiles xg-cs-2.po" +: ${XGETTEXT=xgettext} +# delete POT-Creation-Date: line because the date depends on local time. +${XGETTEXT} --output - --add-location -c --from-code=UTF-8 xg-cs-2.cs \ + | sed '/\"POT-Creation-Date:.*/d' > xg-cs-2.po +test $? = 0 || { rm -fr $tmpfiles; exit 1; } + +tmpfiles="$tmpfiles xg-cs-2.ok" +cat <<\EOF > xg-cs-2.ok +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: xg-cs-2.cs:3 xg-cs-2.cs:8 +msgid "Russian (Русский): Здравствуйте" +msgstr "" + +#: xg-cs-2.cs:4 xg-cs-2.cs:9 +msgid "Vietnamese (Tiếng Việt): Chào bạn" +msgstr "" + +#: xg-cs-2.cs:5 xg-cs-2.cs:10 +msgid "Japanese (日本語): こんにちは" +msgstr "" + +#: xg-cs-2.cs:6 xg-cs-2.cs:11 +msgid "Thai (ภาษาไทย): สวัสดีครับ" +msgstr "" + +#: xg-cs-2.cs:7 xg-cs-2.cs:12 +msgid "Script: 𝒞" +msgstr "" + +#. And now a comment with Русский and 日本語 and Unicode escapes: B\u00f6se B\u00fcbchen +#: xg-cs-2.cs:14 +msgid "This string has a multilingual comment" +msgstr "" +EOF + +: ${DIFF=diff} +${DIFF} xg-cs-2.ok xg-cs-2.po +result=$? + +rm -fr $tmpfiles + +exit $result diff --git a/gettext-tools/tests/xgettext-csharp-3 b/gettext-tools/tests/xgettext-csharp-3 new file mode 100755 index 0000000..4a3ee3e --- /dev/null +++ b/gettext-tools/tests/xgettext-csharp-3 @@ -0,0 +1,178 @@ +#!/bin/sh + +# More tests for C# support: string syntax + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles xg-cs-3.cs" +tr '%' '\015' <<\EOF > xg-cs-3.cs +class TestCase { + public static void Main (String[] args) { + // Test recognition of \u escapes. + GetString ("B\u00f6se B\u00fcbchen"); + // \u escapes with more than one u are invalid. + GetString ("Japanese: \uu65e5\uuu672c\u8A9e"); + GetString ("embedded\nnewline"); + // Spaces from end of comment are removed. %GetString("dummy"); + // Two backslashes (unlike in Java, where this is just one backslash). + GetString ("\u005c\u005c"); + // A 6-character string (unlike in Java, where this is just one backslash). + GetString ("\\u005c"); + // A single backslash. + GetString ("\\"); + // There is only one \u recognition pass. + GetString ("\u005cu005c"); + // Octal escape sequences are not recognized, except for \0. + GetString ("\134"); + // Escape sequences in strings. + GetString ("t -> \t, b -> \b, n -> \n, dquote -> \", squote -> \' ..."); + // Hex escapes are recognized. + GetString ("bel: \x07\n"); + GetString // Recognized despite comments + ( /* Even across multiline +comment! */ "this is a single " /* now comes the concatenation! */ + // after + + "long line"); + // Verbatim string literals are extracted. + GetString (@"verbatim 1"); + // In verbatim string literals, no escape sequences are recognized. + GetString (@"verbatim 2 \u005c \\ \t \b \n \'"); + // In verbatim string literals, only doubled delimiters are recognized. + GetString (@"verbatim 3 ""test"); + // Normal and verbatim string literals can be concatenated. + GetString ("left - \"quot" + @"ation"" - right"); + // Character literals are not extracted. + GetString ('x'); + // Invalid concatenations are not concatenated. + GetString ("fooba"+'r'); + // Verify that a comma inside braces is hidden. + MyGetString (new Object[] { "don't", "fool", "me" }, "this is the second argument"); + } +} +EOF + +tmpfiles="$tmpfiles xg-cs-3.po" +: ${XGETTEXT=xgettext} +# delete POT-Creation-Date: line because the date depends on local time. +${XGETTEXT} --output - --add-location -c -kMyGetString:2 xg-cs-3.cs 2>/dev/null \ + | sed '/\"POT-Creation-Date:.*/d' > xg-cs-3.po +test $? = 0 || { rm -fr $tmpfiles; exit 1; } + +tmpfiles="$tmpfiles xg-cs-3.ok" +cat <<\EOF > xg-cs-3.ok +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Test recognition of \u escapes. +#: xg-cs-3.cs:4 +msgid "Böse Bübchen" +msgstr "" + +#. \u escapes with more than one u are invalid. +#: xg-cs-3.cs:6 +msgid "Japanese: \\uu65e5\\uuu672c語" +msgstr "" + +#: xg-cs-3.cs:7 +msgid "" +"embedded\n" +"newline" +msgstr "" + +#. Spaces from end of comment are removed. +#: xg-cs-3.cs:8 +msgid "dummy" +msgstr "" + +#. Two backslashes (unlike in Java, where this is just one backslash). +#: xg-cs-3.cs:10 +msgid "\\\\" +msgstr "" + +#. A 6-character string (unlike in Java, where this is just one backslash). +#. There is only one \u recognition pass. +#: xg-cs-3.cs:12 xg-cs-3.cs:16 +msgid "\\u005c" +msgstr "" + +#. A single backslash. +#: xg-cs-3.cs:14 +msgid "\\" +msgstr "" + +#. Octal escape sequences are not recognized, except for \0. +#: xg-cs-3.cs:18 +msgid "\\134" +msgstr "" + +#. Escape sequences in strings. +#: xg-cs-3.cs:20 +msgid "" +"t -> \t, b -> \b, n -> \n" +", dquote -> \", squote -> ' ..." +msgstr "" + +#. Hex escapes are recognized. +#: xg-cs-3.cs:22 +msgid "bel: \n" +msgstr "" + +#. Recognized despite comments +#. Even across multiline +#. comment! +#: xg-cs-3.cs:25 +msgid "this is a single long line" +msgstr "" + +#. Verbatim string literals are extracted. +#: xg-cs-3.cs:28 +msgid "verbatim 1" +msgstr "" + +#. In verbatim string literals, no escape sequences are recognized. +#: xg-cs-3.cs:30 +msgid "verbatim 2 \\u005c \\\\ \\t \\b \\n \\'" +msgstr "" + +#. In verbatim string literals, only doubled delimiters are recognized. +#: xg-cs-3.cs:32 +msgid "verbatim 3 \"test" +msgstr "" + +#. Normal and verbatim string literals can be concatenated. +#: xg-cs-3.cs:34 +msgid "left - \"quotation\" - right" +msgstr "" + +#. Invalid concatenations are not concatenated. +#: xg-cs-3.cs:38 +msgid "fooba" +msgstr "" + +#. Verify that a comma inside braces is hidden. +#: xg-cs-3.cs:40 +msgid "this is the second argument" +msgstr "" +EOF + +: ${DIFF=diff} +${DIFF} xg-cs-3.ok xg-cs-3.po +result=$? + +rm -fr $tmpfiles + +exit $result diff --git a/gettext-tools/tests/xgettext-csharp-4 b/gettext-tools/tests/xgettext-csharp-4 new file mode 100755 index 0000000..8189fd7 --- /dev/null +++ b/gettext-tools/tests/xgettext-csharp-4 @@ -0,0 +1,42 @@ +#!/bin/sh + +# Tests for C# plural keyword support + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles xg-cs-4.cs" +cat <<EOF > xg-cs-4.cs +class TestCase { + public static void Main (String[] args) { + GetPluralString("test 1", "plural test"); + MyPluralString (context, "I've 1", "you've lost"); + } +} +EOF + +tmpfiles="$tmpfiles xg-cs-4.po" +: ${XGETTEXT=xgettext} +${XGETTEXT} --omit-header --no-location --keyword=MyPluralString:2,3 -d xg-cs-4 xg-cs-4.cs +test $? = 0 || { rm -fr $tmpfiles; exit 1; } + +tmpfiles="$tmpfiles xg-cs-4.ok" +cat <<EOF > xg-cs-4.ok +msgid "test 1" +msgid_plural "plural test" +msgstr[0] "" +msgstr[1] "" + +msgid "I've 1" +msgid_plural "you've lost" +msgstr[0] "" +msgstr[1] "" +EOF + +: ${DIFF=diff} +${DIFF} xg-cs-4.ok xg-cs-4.po +result=$? + +rm -fr $tmpfiles + +exit $result diff --git a/gettext-tools/tests/xgettext-csharp-5 b/gettext-tools/tests/xgettext-csharp-5 new file mode 100755 index 0000000..a9a525d --- /dev/null +++ b/gettext-tools/tests/xgettext-csharp-5 @@ -0,0 +1,53 @@ +#!/bin/sh + +# Test C# support: --add-comments option. + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles xg-cs-5.cs" +cat <<EOF > xg-cs-5.cs +// This comment will not be extracted. +Console.WriteLine(GetString("help")); +// TRANSLATORS: This is an extracted comment. +Console.WriteLine(GetString("me")); +/* Not extracted either. */ +Console.WriteLine(GetString("Hey Jude")); +/* TRANSLATORS: + Nickname of the Beatles +*/ +Console.WriteLine(GetString("The Fabulous Four")); +EOF + +tmpfiles="$tmpfiles xg-cs-5.po" +: ${XGETTEXT=xgettext} +${XGETTEXT} --omit-header --no-location --add-comments=TRANSLATORS: \ + xg-cs-5.cs -d xg-cs-5 +test $? = 0 || { rm -fr $tmpfiles; exit 1; } + +tmpfiles="$tmpfiles xg-cs-5.ok" +cat <<EOF > xg-cs-5.ok +msgid "help" +msgstr "" + +#. TRANSLATORS: This is an extracted comment. +msgid "me" +msgstr "" + +msgid "Hey Jude" +msgstr "" + +#. TRANSLATORS: +#. Nickname of the Beatles +#. +msgid "The Fabulous Four" +msgstr "" +EOF + +: ${DIFF=diff} +${DIFF} xg-cs-5.ok xg-cs-5.po +result=$? + +rm -fr $tmpfiles + +exit $result |