3 # Test of gettext facilities in the bash language.
4 # Assumes an fr_FR locale is installed.
5 # Assumes the following packages are installed: bash 2.0 or newer.
7 # This test fails on MacOS X 10.5 because its 'bash' command is built with
8 # an included intl directory without iconv support; hence it produces wrong
9 # output when accessing any .mo file not generated from a .po file in UTF-8
13 trap 'rm -fr $tmpfiles' 1 2 3 15
15 tmpfiles="$tmpfiles prog.sh"
28 $echo $"'Your command, please?', asked the waiter."
30 $echo "`eval_ngettext "a piece of cake" "\\$n pieces of cake" $n`"
33 tmpfiles="$tmpfiles prog.tmp prog.pot prog.err"
34 : ${XGETTEXT=xgettext}
35 LC_MESSAGES=C LC_ALL= \
36 ${XGETTEXT} -o prog.tmp --omit-header --no-location prog.sh \
39 cat prog.err | grep -v 'warning: the syntax \$"\.\.\." is deprecated due to security reasons'
40 test $result = 0 || { rm -fr $tmpfiles; exit 1; }
41 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot
42 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
44 tmpfiles="$tmpfiles prog.ok"
46 msgid "'Your command, please?', asked the waiter."
50 msgid "a piece of cake"
51 msgid_plural "$n pieces of cake"
57 ${DIFF} prog.ok prog.pot || exit 1
59 tmpfiles="$tmpfiles fr.po"
63 "Content-Type: text/plain; charset=ISO-8859-1\n"
64 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
66 msgid "'Your command, please?', asked the waiter."
67 msgstr "«Votre commande, s'il vous plait», dit le garçon."
69 # Les gateaux allemands sont les meilleurs du monde.
71 msgid "a piece of cake"
72 msgid_plural "$n pieces of cake"
73 msgstr[0] "un morceau de gateau"
74 msgstr[1] "$n morceaux de gateau"
77 tmpfiles="$tmpfiles fr.po.tmp fr.po.new"
78 : ${MSGMERGE=msgmerge}
79 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot
80 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
81 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new
82 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
85 ${DIFF} fr.po fr.po.new || exit 1
87 tmpfiles="$tmpfiles fr"
88 test -d fr || mkdir fr
89 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
92 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
94 # Test for presence of bash version 2.0 or newer.
95 (bash -c :) >/dev/null 2>/dev/null \
96 || { echo "Skipping test: bash not found"; rm -fr $tmpfiles; exit 77; }
97 case `bash -c 'echo $BASH_VERSION'` in
99 *) echo "Skipping test: bash version too old"; rm -fr $tmpfiles; exit 77;;
102 # Test which of the fr_FR locales are installed.
104 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
105 if test $LOCALE_FR != none; then
106 LC_ALL=$LOCALE_FR ./testlocale
113 if test $LOCALE_FR_UTF8 != none; then
114 LC_ALL=$LOCALE_FR_UTF8 ./testlocale
117 77) LOCALE_FR_UTF8=none;;
121 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
122 if test -f /usr/bin/localedef; then
123 echo "Skipping test: no french locale is installed"
125 echo "Skipping test: no french locale is supported"
127 rm -fr $tmpfiles; exit 77
130 tmpfiles="$tmpfiles prog.nok prog.ok prog.oku prog.out"
131 # Expected result when bash is built without i18n support.
132 cat <<\EOF > prog.nok
133 'Your command, please?', asked the waiter.
136 # Expected result when bash is built with i18n support.
138 «Votre commande, s'il vous plait», dit le garçon.
141 cat <<\EOF > prog.oku
142 «Votre commande, s'il vous plait», dit le garçon.
147 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
148 if test $LOCALE_FR != none; then
149 LANGUAGE= LC_ALL=$LOCALE_FR bash ./prog.sh 2 > prog.out || exit 1
151 ${DIFF} prog.nok prog.out > /dev/null && {
152 echo "Skipping test: bash is built without i18n support"
153 rm -fr $tmpfiles; exit 77
155 ${DIFF} prog.ok prog.out || exit 1
157 if test $LOCALE_FR_UTF8 != none; then
158 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 bash ./prog.sh 2 > prog.out || exit 1
160 ${DIFF} prog.nok prog.out > /dev/null && {
161 echo "Skipping test: bash is built without i18n support"
162 rm -fr $tmpfiles; exit 77
164 ${DIFF} prog.oku prog.out || exit 1