2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src ${top_srcdir=..}/../gettext-runtime/src
4 # Test of gettext facilities in the bash language.
5 # Assumes an fr_FR locale is installed.
6 # Assumes the following packages are installed: bash 2.0 or newer.
8 # This test fails on MacOS X 10.5 because its 'bash' command is built with
9 # an included intl directory without iconv support; hence it produces wrong
10 # output when accessing any .mo file not generated from a .po file in UTF-8
13 cat <<\EOF > prog.bash
25 $echo $"'Your command, please?', asked the waiter."
27 $echo "`eval_ngettext "a piece of cake" "\\$n pieces of cake" $n`"
30 : ${XGETTEXT=xgettext}
31 LC_MESSAGES=C LC_ALL= \
32 ${XGETTEXT} -o prog.tmp --omit-header --no-location prog.bash \
35 cat prog.err | grep -v 'warning: the syntax \$"\.\.\." is deprecated due to security reasons'
36 test $result = 0 || { exit 1; }
37 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || exit 1
40 msgid "'Your command, please?', asked the waiter."
44 msgid "a piece of cake"
45 msgid_plural "$n pieces of cake"
51 ${DIFF} prog.ok prog.pot || exit 1
56 "Content-Type: text/plain; charset=ISO-8859-1\n"
57 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
59 msgid "'Your command, please?', asked the waiter."
60 msgstr "«Votre commande, s'il vous plait», dit le garçon."
62 # Les gateaux allemands sont les meilleurs du monde.
64 msgid "a piece of cake"
65 msgid_plural "$n pieces of cake"
66 msgstr[0] "un morceau de gateau"
67 msgstr[1] "$n morceaux de gateau"
70 : ${MSGMERGE=msgmerge}
71 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || exit 1
72 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || exit 1
75 ${DIFF} fr.po fr.po.new || exit 1
77 test -d fr || mkdir fr
78 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
81 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
83 # Test for presence of bash version 2.0 or newer.
84 (bash -c :) >/dev/null 2>/dev/null \
85 || { echo "Skipping test: bash not found"; exit 77; }
86 case `bash -c 'echo $BASH_VERSION'` in
88 *) echo "Skipping test: bash version too old"; exit 77;;
91 # Test which of the fr_FR locales are installed.
93 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
94 if test $LOCALE_FR != none; then
95 LC_ALL=$LOCALE_FR ../testlocale
102 if test $LOCALE_FR_UTF8 != none; then
103 LC_ALL=$LOCALE_FR_UTF8 ../testlocale
106 77) LOCALE_FR_UTF8=none;;
110 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
111 if test -f /usr/bin/localedef; then
112 echo "Skipping test: no french locale is installed"
114 echo "Skipping test: no french locale is supported"
121 if test $LOCALE_FR != none; then
122 LC_ALL=$LOCALE_FR bash --help \
123 | grep '^Utilisation' > /dev/null 2>&1 || exit 77
125 if test $LOCALE_FR_UTF8 != none; then
126 LC_ALL=$LOCALE_FR_UTF8 bash --help \
127 | grep '^Utilisation' > /dev/null 2>&1 || exit 77
132 # Expected result when bash is built without i18n support.
133 cat <<\EOF > prog.nok
134 'Your command, please?', asked the waiter.
137 # Expected result when bash is built with i18n support.
139 «Votre commande, s'il vous plait», dit le garçon.
142 cat <<\EOF > prog.oku
143 «Votre commande, s'il vous plait», dit le garçon.
148 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
149 if test $LOCALE_FR != none; then
150 prepare_locale_ fr $LOCALE_FR
151 LANGUAGE= LC_ALL=$LOCALE_FR bash ./prog.bash 2 > prog.out || exit 1
153 ${DIFF} prog.nok prog.out > /dev/null && {
154 echo "Skipping test: bash is built without i18n support"
157 ${DIFF} prog.ok prog.out || exit 1
159 if test $LOCALE_FR_UTF8 != none; then
160 prepare_locale_ fr $LOCALE_FR_UTF8
161 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 bash ./prog.bash 2 > prog.out || exit 1
163 ${DIFF} prog.nok prog.out > /dev/null && {
164 echo "Skipping test: bash is built without i18n support"
167 ${DIFF} prog.oku prog.out || exit 1