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.
8 trap 'rm -fr $tmpfiles' 1 2 3 15
10 tmpfiles
="$tmpfiles prog.sh"
23 $echo $
"'Your command, please?', asked the waiter."
25 $echo "`eval_ngettext "a piece of cake
" "\\$n pieces of cake
" $n`"
28 tmpfiles
="$tmpfiles prog.pot prog.err"
29 : ${XGETTEXT=xgettext}
30 LC_MESSAGES
=C LC_ALL
= \
31 ${XGETTEXT} -o prog.pot
--omit-header --no-location prog.sh \
34 cat prog.err |
grep -v 'warning: the syntax \$"\.\.\." is deprecated due to security reasons'
35 test $result = 0 ||
{ rm -fr $tmpfiles; exit 1; }
37 tmpfiles
="$tmpfiles prog.ok"
39 msgid
"'Your command, please?', asked the waiter."
43 msgid
"a piece of cake"
44 msgid_plural
"$n pieces of cake"
50 ${DIFF} prog.ok prog.pot ||
exit 1
52 tmpfiles
="$tmpfiles fr.po"
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 tmpfiles
="$tmpfiles fr.po.new"
71 : ${MSGMERGE=msgmerge}
72 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
75 ${DIFF} fr.po fr.po.new ||
exit 1
77 tmpfiles
="$tmpfiles fr"
78 test -d fr || mkdir fr
79 test -d fr
/LC_MESSAGES || mkdir fr
/LC_MESSAGES
82 ${MSGFMT} -o fr
/LC_MESSAGES
/prog.mo fr.po
84 # Test for presence of bash version 2.0 or newer.
85 (bash
-c :) >/dev
/null
2>/dev
/null \
86 ||
{ rm -fr $tmpfiles; exit 77; }
87 case `bash -c 'echo $BASH_VERSION'` in
89 *) rm -fr $tmpfiles; exit 77;;
92 # Test which of the fr_FR locales are installed.
94 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
95 if test $LOCALE_FR != none
; then
96 LC_ALL
=$LOCALE_FR .
/testlocale
103 if test $LOCALE_FR_UTF8 != none
; then
104 LC_ALL
=$LOCALE_FR_UTF8 .
/testlocale
107 77) LOCALE_FR_UTF8
=none
;;
111 if test $LOCALE_FR = none
&& test $LOCALE_FR_UTF8 = none
; then
112 rm -fr $tmpfiles; exit 77
115 tmpfiles
="$tmpfiles prog.nok prog.ok prog.oku prog.out"
116 # Expected result when bash is built without i18n support.
117 cat <<\EOF
> prog.nok
118 'Your command, please?', asked the waiter.
121 # Expected result when bash is built with i18n support.
123 «Votre commande
, s
'il vous plait», dit le garçon.
126 cat <<\EOF > prog.oku
127 «Votre commande, s'il vous plait»
, dit le garçon.
132 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
133 if test $LOCALE_FR != none
; then
134 LANGUAGE
= LC_ALL
=$LOCALE_FR bash .
/prog.sh
2 > prog.out ||
exit 1
136 ${DIFF} prog.nok prog.out
> /dev
/null
&& { rm -fr $tmpfiles; exit 77; }
137 ${DIFF} prog.ok prog.out ||
exit 1
139 if test $LOCALE_FR_UTF8 != none
; then
140 LANGUAGE
= LC_ALL
=$LOCALE_FR_UTF8 bash .
/prog.sh
2 > prog.out ||
exit 1
142 ${DIFF} prog.nok prog.out
> /dev
/null
&& { rm -fr $tmpfiles; exit 77; }
143 ${DIFF} prog.oku prog.out ||
exit 1