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 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")); 48 } 49} 50EOF 51 52tmpfiles="$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 55 56tmpfiles="$tmpfiles prog.tmp prog.pot" 57: ${XGETTEXT=xgettext} 58${XGETTEXT} -o prog.tmp --omit-header --no-location program.cs 59test $? = 0 || { rm -fr $tmpfiles; exit 1; } 60tr -d '\r' < prog.tmp > prog.pot 61test $? = 0 || { rm -fr $tmpfiles; exit 1; } 62 63tmpfiles="$tmpfiles prog.ok" 64cat <<EOF > prog.ok 65msgid "'Your command, please?', asked the waiter." 66msgstr "" 67 68#, csharp-format 69msgid "a piece of cake" 70msgid_plural "{0} pieces of cake" 71msgstr[0] "" 72msgstr[1] "" 73 74#, csharp-format 75msgid "{0} is replaced by {1}." 76msgstr "" 77 78#, csharp-format 79msgctxt "++" 80msgid "a piece of cake" 81msgid_plural "{0} pieces of cake" 82msgstr[0] "" 83msgstr[1] "" 84 85#, csharp-format 86msgctxt "++" 87msgid "{0} is replaced by {1}." 88msgstr "" 89EOF 90 91: ${DIFF=diff} 92${DIFF} prog.ok prog.pot || exit 1 93 94tmpfiles="$tmpfiles fr.po" 95cat <<\EOF > fr.po 96msgid "" 97msgstr "" 98"Content-Type: text/plain; charset=ISO-8859-1\n" 99"Plural-Forms: nplurals=2; plural=(n > 1);\n" 100 101msgid "'Your command, please?', asked the waiter." 102msgstr "�Votre commande, s'il vous plait�, dit le gar�on." 103 104# Les gateaux allemands sont les meilleurs du monde. 105#, csharp-format 106msgid "a piece of cake" 107msgid_plural "{0} pieces of cake" 108msgstr[0] "un morceau de gateau" 109msgstr[1] "{0} morceaux de gateau" 110 111# Reverse the arguments. 112#, csharp-format 113msgid "{0} is replaced by {1}." 114msgstr "{1} remplace {0}." 115 116# Euphemistic formulation. 117#, csharp-format 118msgctxt "++" 119msgid "a piece of cake" 120msgid_plural "{0} pieces of cake" 121msgstr[0] "un morceau de gateau succulent" 122msgstr[1] "{0} morceaux de gateau succulent" 123 124# Euphemistic formulation. 125#, csharp-format 126msgctxt "++" 127msgid "{0} is replaced by {1}." 128msgstr "Le nouveau {1} remplace le vieux {0}." 129EOF 130 131tmpfiles="$tmpfiles fr.po.tmp fr.po.new" 132: ${MSGMERGE=msgmerge} 133${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot 134test $? = 0 || { rm -fr $tmpfiles; exit 1; } 135tr -d '\r' < fr.po.tmp > fr.po.new 136test $? = 0 || { rm -fr $tmpfiles; exit 1; } 137 138: ${DIFF=diff} 139${DIFF} fr.po fr.po.new || exit 1 140 141tmpfiles="$tmpfiles fr/prog.dll" 142: ${MSGFMT=msgfmt} 143GETTEXTCSHARPLIBDIR=../../gettext-runtime/intl-csharp \ 144${MSGFMT} --csharp -d . -r prog -l fr fr.po || exit 1 145 146# Test which of the fr_FR locales are installed. 147: ${LOCALE_FR=fr_FR} 148: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 149if test $LOCALE_FR != none; then 150 LC_ALL=$LOCALE_FR ./testlocale 151 case $? in 152 0) ;; 153 77) LOCALE_FR=none;; 154 *) exit 1;; 155 esac 156fi 157if test $LOCALE_FR_UTF8 != none; then 158 LC_ALL=$LOCALE_FR_UTF8 ./testlocale 159 case $? in 160 0) ;; 161 77) LOCALE_FR_UTF8=none;; 162 *) exit 1;; 163 esac 164fi 165if 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" 168 else 169 echo "Skipping test: no french locale is supported" 170 fi 171 rm -fr $tmpfiles; exit 77 172fi 173 174tmpfiles="$tmpfiles prog.ok prog.oku prog.out" 175: ${DIFF=diff} 176cat <<\EOF > prog.ok 177�Votre commande, s'il vous plait�, dit le gar�on. 1782 morceaux de gateau 179EUR remplace FF. 1802 morceaux de gateau succulent 181Le nouveau EUR remplace le vieux FF. 182EOF 183cat <<\EOF > prog.oku 184��Votre commande, s'il vous plait��, dit le gar��on. 1852 morceaux de gateau 186EUR remplace FF. 1872 morceaux de gateau succulent 188Le nouveau EUR remplace le vieux FF. 189EOF 190 191: ${LOCALE_FR=fr_FR} 192: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 193: ${CSHARPEXEC="/bin/sh ../csharpexec.sh"} 194if 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 197fi 198if 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 201fi 202 203rm -fr $tmpfiles 204 205exit 0 206