3 # Test of gettext facilities in the C# language.
4 # Assumes an fr_FR locale is installed.
5 # Assumes the following packages are installed: pnet, pnetlib.
7 # Note: This test fails with mono-0.28 because the CultureInfo.Parent pointers
8 # are wrong for locales containing a language and a territory. This is fixed
12 trap 'rm -fr $tmpfiles' 1 2 3 15
14 # Test whether we can build and test C# programs.
15 test "${CSHARP_CHOICE}" != no || {
16 echo "Skipping test: configured with --disable-csharp"
19 test "${BUILDCSHARP}" = yes || {
20 echo "Skipping test: C# compiler not found"
23 test "${TESTCSHARP}" = yes || {
24 echo "Skipping test: C# engine not found"
28 tmpfiles="$tmpfiles program.cs"
29 cat <<\EOF > program.cs
33 static void Main (String[] args) {
35 // Some systems don't set CurrentCulture and CurrentUICulture as specified
36 // by LC_ALL. So set it by hand.
37 System.Threading.Thread.CurrentThread.CurrentCulture =
38 System.Threading.Thread.CurrentThread.CurrentUICulture =
39 new System.Globalization.CultureInfo("fr-FR");
41 int n = Int32.Parse(args[0]);
42 GettextResourceManager catalog = new GettextResourceManager("prog");
43 Console.WriteLine(catalog.GetString("'Your command, please?', asked the waiter."));
44 Console.WriteLine(String.Format(catalog.GetPluralString("a piece of cake","{0} pieces of cake",n), n));
45 Console.WriteLine(String.Format(catalog.GetString("{0} is replaced by {1}."), "FF", "EUR"));
46 Console.WriteLine(String.Format(catalog.GetParticularPluralString("++","a piece of cake","{0} pieces of cake",n), n));
47 Console.WriteLine(String.Format(catalog.GetParticularString("++","{0} is replaced by {1}."), "FF", "EUR"));
52 tmpfiles="$tmpfiles program.exe"
53 : ${CSHARPCOMP="/bin/sh ../csharpcomp.sh"}
54 ${CSHARPCOMP} -o program.exe -L ../../gettext-runtime/intl-csharp -l GNU.Gettext program.cs || exit 1
56 tmpfiles="$tmpfiles prog.tmp prog.pot"
57 : ${XGETTEXT=xgettext}
58 ${XGETTEXT} -o prog.tmp --omit-header --no-location program.cs
59 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
60 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot
61 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
63 tmpfiles="$tmpfiles prog.ok"
65 msgid "'Your command, please?', asked the waiter."
69 msgid "a piece of cake"
70 msgid_plural "{0} pieces of cake"
75 msgid "{0} is replaced by {1}."
80 msgid "a piece of cake"
81 msgid_plural "{0} pieces of cake"
87 msgid "{0} is replaced by {1}."
92 ${DIFF} prog.ok prog.pot || exit 1
94 tmpfiles="$tmpfiles fr.po"
98 "Content-Type: text/plain; charset=ISO-8859-1\n"
99 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
101 msgid "'Your command, please?', asked the waiter."
102 msgstr "«Votre commande, s'il vous plait», dit le garçon."
104 # Les gateaux allemands sont les meilleurs du monde.
106 msgid "a piece of cake"
107 msgid_plural "{0} pieces of cake"
108 msgstr[0] "un morceau de gateau"
109 msgstr[1] "{0} morceaux de gateau"
111 # Reverse the arguments.
113 msgid "{0} is replaced by {1}."
114 msgstr "{1} remplace {0}."
116 # Euphemistic formulation.
119 msgid "a piece of cake"
120 msgid_plural "{0} pieces of cake"
121 msgstr[0] "un morceau de gateau succulent"
122 msgstr[1] "{0} morceaux de gateau succulent"
124 # Euphemistic formulation.
127 msgid "{0} is replaced by {1}."
128 msgstr "Le nouveau {1} remplace le vieux {0}."
131 tmpfiles="$tmpfiles fr.po.tmp fr.po.new"
132 : ${MSGMERGE=msgmerge}
133 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot
134 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
135 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new
136 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
139 ${DIFF} fr.po fr.po.new || exit 1
141 tmpfiles="$tmpfiles fr/prog.dll"
143 GETTEXTCSHARPLIBDIR=../../gettext-runtime/intl-csharp \
144 ${MSGFMT} --csharp -d . -r prog -l fr fr.po || exit 1
146 # Test which of the fr_FR locales are installed.
148 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
149 if test $LOCALE_FR != none; then
150 LC_ALL=$LOCALE_FR ./testlocale
157 if test $LOCALE_FR_UTF8 != none; then
158 LC_ALL=$LOCALE_FR_UTF8 ./testlocale
161 77) LOCALE_FR_UTF8=none;;
165 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
166 if test -f /usr/bin/localedef; then
167 echo "Skipping test: no french locale is installed"
169 echo "Skipping test: no french locale is supported"
171 rm -fr $tmpfiles; exit 77
174 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
177 «Votre commande, s'il vous plait», dit le garçon.
180 2 morceaux de gateau succulent
181 Le nouveau EUR remplace le vieux FF.
183 cat <<\EOF > prog.oku
184 «Votre commande, s'il vous plait», dit le garçon.
187 2 morceaux de gateau succulent
188 Le nouveau EUR remplace le vieux FF.
192 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
193 : ${CSHARPEXEC="/bin/sh ../csharpexec.sh"}
194 if test $LOCALE_FR != none; then
195 LANGUAGE= LC_ALL=$LOCALE_FR ${CSHARPEXEC} -L ../../gettext-runtime/intl-csharp program.exe 2 > prog.out || exit 1
196 ${DIFF} prog.ok prog.out || exit 1
198 if test $LOCALE_FR_UTF8 != none; then
199 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 ${CSHARPEXEC} -L ../../gettext-runtime/intl-csharp program.exe 2 > prog.out || exit 1
200 ${DIFF} prog.oku prog.out || exit 1