No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / lang-csharp
blob27a4c86eb5777702ff59186afd85329edd80ce62
1 #! /bin/sh
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
9 # in mono-0.29.
11 tmpfiles=""
12 trap 'rm -fr $tmpfiles' 1 2 3 15
14 # Test whether we can build and test C# programs.
15 test "${TESTCSHARP}" = yes || exit 77
17 tmpfiles="$tmpfiles program.cs"
18 cat <<\EOF > program.cs
19 using System;
20 using GNU.Gettext;
21 class Program {
22 static void Main (String[] args) {
23 #if __MonoCS__
24 // Some systems don't set CurrentCulture and CurrentUICulture as specified
25 // by LC_ALL. So set it by hand.
26 System.Threading.Thread.CurrentThread.CurrentCulture =
27 System.Threading.Thread.CurrentThread.CurrentUICulture =
28 new System.Globalization.CultureInfo("fr-FR");
29 #endif
30 int n = Int32.Parse(args[0]);
31 GettextResourceManager catalog = new GettextResourceManager("prog");
32 Console.WriteLine(catalog.GetString("'Your command, please?', asked the waiter."));
33 Console.WriteLine(String.Format(catalog.GetPluralString("a piece of cake","{0} pieces of cake",n), n));
34 Console.WriteLine(String.Format(catalog.GetString("{0} is replaced by {1}."), "FF", "EUR"));
37 EOF
39 tmpfiles="$tmpfiles program.exe"
40 : ${CSHARPCOMP="/bin/sh ../lib/csharpcomp.sh"}
41 ${CSHARPCOMP} -o program.exe -L ../../gettext-runtime/intl-csharp -l GNU.Gettext program.cs || exit 1
43 tmpfiles="$tmpfiles prog.pot"
44 : ${XGETTEXT=xgettext}
45 ${XGETTEXT} -o prog.pot --omit-header --no-location program.cs
47 tmpfiles="$tmpfiles prog.ok"
48 cat <<EOF > prog.ok
49 msgid "'Your command, please?', asked the waiter."
50 msgstr ""
52 #, csharp-format
53 msgid "a piece of cake"
54 msgid_plural "{0} pieces of cake"
55 msgstr[0] ""
56 msgstr[1] ""
58 #, csharp-format
59 msgid "{0} is replaced by {1}."
60 msgstr ""
61 EOF
63 : ${DIFF=diff}
64 ${DIFF} prog.ok prog.pot || exit 1
66 tmpfiles="$tmpfiles fr.po"
67 cat <<\EOF > fr.po
68 msgid ""
69 msgstr ""
70 "Content-Type: text/plain; charset=ISO-8859-1\n"
71 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
73 msgid "'Your command, please?', asked the waiter."
74 msgstr "«Votre commande, s'il vous plait», dit le garçon."
76 # Les gateaux allemands sont les meilleurs du monde.
77 #, csharp-format
78 msgid "a piece of cake"
79 msgid_plural "{0} pieces of cake"
80 msgstr[0] "un morceau de gateau"
81 msgstr[1] "{0} morceaux de gateau"
83 # Reverse the arguments.
84 #, csharp-format
85 msgid "{0} is replaced by {1}."
86 msgstr "{1} remplace {0}."
87 EOF
89 tmpfiles="$tmpfiles fr.po.new"
90 : ${MSGMERGE=msgmerge}
91 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
93 : ${DIFF=diff}
94 ${DIFF} fr.po fr.po.new || exit 1
96 tmpfiles="$tmpfiles fr/prog.dll"
97 : ${MSGFMT=msgfmt}
98 GETTEXTCSHARPLIBDIR=../../gettext-runtime/intl-csharp \
99 ${MSGFMT} --csharp -d . -r prog -l fr fr.po || exit 1
101 # Test which of the fr_FR locales are installed.
102 : ${LOCALE_FR=fr_FR}
103 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
104 if test $LOCALE_FR != none; then
105 LC_ALL=$LOCALE_FR ./testlocale
106 case $? in
107 0) ;;
108 77) LOCALE_FR=none;;
109 *) exit 1;;
110 esac
112 if test $LOCALE_FR_UTF8 != none; then
113 LC_ALL=$LOCALE_FR_UTF8 ./testlocale
114 case $? in
115 0) ;;
116 77) LOCALE_FR_UTF8=none;;
117 *) exit 1;;
118 esac
120 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
121 rm -fr $tmpfiles; exit 77
124 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
125 : ${DIFF=diff}
126 cat <<\EOF > prog.ok
127 «Votre commande, s'il vous plait», dit le garçon.
128 2 morceaux de gateau
129 EUR remplace FF.
131 cat <<\EOF > prog.oku
132 «Votre commande, s'il vous plait», dit le garçon.
133 2 morceaux de gateau
134 EUR remplace FF.
137 : ${LOCALE_FR=fr_FR}
138 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
139 : ${CSHARPEXEC="/bin/sh ../lib/csharpexec.sh"}
140 if test $LOCALE_FR != none; then
141 LANGUAGE= LC_ALL=$LOCALE_FR ${CSHARPEXEC} -L ../../gettext-runtime/intl-csharp program.exe 2 > prog.out || exit 1
142 ${DIFF} prog.ok prog.out || exit 1
144 if test $LOCALE_FR_UTF8 != none; then
145 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 ${CSHARPEXEC} -L ../../gettext-runtime/intl-csharp program.exe 2 > prog.out || exit 1
146 ${DIFF} prog.oku prog.out || exit 1
149 rm -fr $tmpfiles
151 exit 0