No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / lang-sh
blobbaca02a6b03d0b1afbf1961223bda2b9138470b7
1 #! /bin/sh
3 # Test of gettext facilities in the sh language.
4 # Assumes an fr_FR locale is installed.
5 # Assumes the following packages are installed: bash.
7 # Note: This test fails on BeOS because there all locales use the UTF-8
8 # encoding, even the locale fr_FR, thus the output comes out in UTF-8.
10 tmpfiles=""
11 trap 'rm -fr $tmpfiles' 1 2 3 15
13 tmpfiles="$tmpfiles prog.sh"
14 cat <<\EOF > prog.sh
15 #! /bin/sh
17 n=$1
19 . gettext.sh
21 TEXTDOMAIN=prog
22 export TEXTDOMAIN
23 TEXTDOMAINDIR=.
24 export TEXTDOMAINDIR
26 $echo "`gettext \"'Your command, please?', asked the waiter.\"`"
28 $echo "`eval_ngettext \"a piece of cake\" \"\\$n pieces of cake\" $n`"
29 EOF
31 tmpfiles="$tmpfiles prog.pot"
32 : ${XGETTEXT=xgettext}
33 ${XGETTEXT} -o prog.pot --omit-header --no-location prog.sh
35 tmpfiles="$tmpfiles prog.ok"
36 cat <<\EOF > prog.ok
37 msgid "'Your command, please?', asked the waiter."
38 msgstr ""
40 #, sh-format
41 msgid "a piece of cake"
42 msgid_plural "$n pieces of cake"
43 msgstr[0] ""
44 msgstr[1] ""
45 EOF
47 : ${DIFF=diff}
48 ${DIFF} prog.ok prog.pot || exit 1
50 tmpfiles="$tmpfiles fr.po"
51 cat <<\EOF > fr.po
52 msgid ""
53 msgstr ""
54 "Content-Type: text/plain; charset=ISO-8859-1\n"
55 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
57 msgid "'Your command, please?', asked the waiter."
58 msgstr "«Votre commande, s'il vous plait», dit le garçon."
60 # Les gateaux allemands sont les meilleurs du monde.
61 #, sh-format
62 msgid "a piece of cake"
63 msgid_plural "$n pieces of cake"
64 msgstr[0] "un morceau de gateau"
65 msgstr[1] "$n morceaux de gateau"
66 EOF
68 tmpfiles="$tmpfiles fr.po.new"
69 : ${MSGMERGE=msgmerge}
70 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
72 : ${DIFF=diff}
73 ${DIFF} fr.po fr.po.new || exit 1
75 tmpfiles="$tmpfiles fr"
76 test -d fr || mkdir fr
77 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
79 : ${MSGFMT=msgfmt}
80 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
82 # Test which of the fr_FR locales are installed.
83 : ${LOCALE_FR=fr_FR}
84 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
85 if test $LOCALE_FR != none; then
86 LC_ALL=$LOCALE_FR ./testlocale
87 case $? in
88 0) ;;
89 77) LOCALE_FR=none;;
90 *) exit 1;;
91 esac
93 if test $LOCALE_FR_UTF8 != none; then
94 LC_ALL=$LOCALE_FR_UTF8 ./testlocale
95 case $? in
96 0) ;;
97 77) LOCALE_FR_UTF8=none;;
98 *) exit 1;;
99 esac
101 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
102 rm -fr $tmpfiles; exit 77
105 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
106 : ${DIFF=diff}
107 cat <<\EOF > prog.ok
108 «Votre commande, s'il vous plait», dit le garçon.
109 2 morceaux de gateau
111 cat <<\EOF > prog.oku
112 «Votre commande, s'il vous plait», dit le garçon.
113 2 morceaux de gateau
116 : ${LOCALE_FR=fr_FR}
117 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
118 if test $LOCALE_FR != none; then
119 LANGUAGE= LC_ALL=$LOCALE_FR sh ./prog.sh 2 > prog.out || exit 1
120 ${DIFF} prog.ok prog.out || exit 1
122 if test $LOCALE_FR_UTF8 != none; then
123 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 sh ./prog.sh 2 > prog.out || exit 1
124 ${DIFF} prog.oku prog.out || exit 1
127 rm -fr $tmpfiles
129 exit 0