lang-csharp revision 1.1.1.1
1#! /bin/sh 2 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. 6 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. 10 11tmpfiles="" 12trap 'rm -fr $tmpfiles' 1 2 3 15 13 14# Test whether we can build and test C# programs. 15test "${CSHARP_CHOICE}" != no || { 16 echo "Skipping test: configured with --disable-csharp" 17 exit 77 18} 19test "${BUILDCSHARP}" = yes || { 20 echo "Skipping test: C# compiler not found" 21 exit 77 22} 23test "${TESTCSHARP}" = yes || { 24 echo "Skipping test: C# engine not found" 25 exit 77 26} 27 28tmpfiles="$tmpfiles program.cs" 29cat <<\EOF > program.cs 30using System; 31using GNU.Gettext; 32class Program { 33 static void Main (String[] args) { 34 #if __MonoCS__ 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"); 40 #endif 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 } 47} 48EOF 49 50tmpfiles="$tmpfiles program.exe" 51: ${CSHARPCOMP="/bin/sh ../csharpcomp.sh"} 52${CSHARPCOMP} -o program.exe -L ../../gettext-runtime/intl-csharp -l GNU.Gettext program.cs || exit 1 53 54tmpfiles="$tmpfiles prog.pot" 55: ${XGETTEXT=xgettext} 56${XGETTEXT} -o prog.pot --omit-header --no-location program.cs 57 58tmpfiles="$tmpfiles prog.ok" 59cat <<EOF > prog.ok 60msgid "'Your command, please?', asked the waiter." 61msgstr "" 62 63#, csharp-format 64msgid "a piece of cake" 65msgid_plural "{0} pieces of cake" 66msgstr[0] "" 67msgstr[1] "" 68 69#, csharp-format 70msgid "{0} is replaced by {1}." 71msgstr "" 72EOF 73 74: ${DIFF=diff} 75${DIFF} prog.ok prog.pot || exit 1 76 77tmpfiles="$tmpfiles fr.po" 78cat <<\EOF > fr.po 79msgid "" 80msgstr "" 81"Content-Type: text/plain; charset=ISO-8859-1\n" 82"Plural-Forms: nplurals=2; plural=(n > 1);\n" 83 84msgid "'Your command, please?', asked the waiter." 85msgstr "�Votre commande, s'il vous plait�, dit le gar�on." 86 87# Les gateaux allemands sont les meilleurs du monde. 88#, csharp-format 89msgid "a piece of cake" 90msgid_plural "{0} pieces of cake" 91msgstr[0] "un morceau de gateau" 92msgstr[1] "{0} morceaux de gateau" 93 94# Reverse the arguments. 95#, csharp-format 96msgid "{0} is replaced by {1}." 97msgstr "{1} remplace {0}." 98EOF 99 100tmpfiles="$tmpfiles fr.po.new" 101: ${MSGMERGE=msgmerge} 102${MSGMERGE} -q -o fr.po.new fr.po prog.pot 103 104: ${DIFF=diff} 105${DIFF} fr.po fr.po.new || exit 1 106 107tmpfiles="$tmpfiles fr/prog.dll" 108: ${MSGFMT=msgfmt} 109GETTEXTCSHARPLIBDIR=../../gettext-runtime/intl-csharp \ 110${MSGFMT} --csharp -d . -r prog -l fr fr.po || exit 1 111 112# Test which of the fr_FR locales are installed. 113: ${LOCALE_FR=fr_FR} 114: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 115if test $LOCALE_FR != none; then 116 LC_ALL=$LOCALE_FR ./testlocale 117 case $? in 118 0) ;; 119 77) LOCALE_FR=none;; 120 *) exit 1;; 121 esac 122fi 123if test $LOCALE_FR_UTF8 != none; then 124 LC_ALL=$LOCALE_FR_UTF8 ./testlocale 125 case $? in 126 0) ;; 127 77) LOCALE_FR_UTF8=none;; 128 *) exit 1;; 129 esac 130fi 131if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then 132 if test -f /usr/bin/localedef; then 133 echo "Skipping test: no french locale is installed" 134 else 135 echo "Skipping test: no french locale is supported" 136 fi 137 rm -fr $tmpfiles; exit 77 138fi 139 140tmpfiles="$tmpfiles prog.ok prog.oku prog.out" 141: ${DIFF=diff} 142cat <<\EOF > prog.ok 143�Votre commande, s'il vous plait�, dit le gar�on. 1442 morceaux de gateau 145EUR remplace FF. 146EOF 147cat <<\EOF > prog.oku 148��Votre commande, s'il vous plait��, dit le gar��on. 1492 morceaux de gateau 150EUR remplace FF. 151EOF 152 153: ${LOCALE_FR=fr_FR} 154: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 155: ${CSHARPEXEC="/bin/sh ../csharpexec.sh"} 156if test $LOCALE_FR != none; then 157 LANGUAGE= LC_ALL=$LOCALE_FR ${CSHARPEXEC} -L ../../gettext-runtime/intl-csharp program.exe 2 > prog.out || exit 1 158 ${DIFF} prog.ok prog.out || exit 1 159fi 160if test $LOCALE_FR_UTF8 != none; then 161 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 ${CSHARPEXEC} -L ../../gettext-runtime/intl-csharp program.exe 2 > prog.out || exit 1 162 ${DIFF} prog.oku prog.out || exit 1 163fi 164 165rm -fr $tmpfiles 166 167exit 0 168