No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / lang-bash
blobf9397b0996b70e622bc642f054c232b0e3b730cb
1 #! /bin/sh
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 tmpfiles=""
8 trap 'rm -fr $tmpfiles' 1 2 3 15
10 tmpfiles="$tmpfiles prog.sh"
11 cat <<\EOF > prog.sh
12 #! /bin/bash
14 n=$1
16 . gettext.sh
18 TEXTDOMAIN=prog
19 export TEXTDOMAIN
20 TEXTDOMAINDIR=.
21 export TEXTDOMAINDIR
23 $echo $"'Your command, please?', asked the waiter."
25 $echo "`eval_ngettext "a piece of cake" "\\$n pieces of cake" $n`"
26 EOF
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 \
32 >prog.err 2>&1
33 result=$?
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"
38 cat <<\EOF > prog.ok
39 msgid "'Your command, please?', asked the waiter."
40 msgstr ""
42 #, sh-format
43 msgid "a piece of cake"
44 msgid_plural "$n pieces of cake"
45 msgstr[0] ""
46 msgstr[1] ""
47 EOF
49 : ${DIFF=diff}
50 ${DIFF} prog.ok prog.pot || exit 1
52 tmpfiles="$tmpfiles fr.po"
53 cat <<\EOF > fr.po
54 msgid ""
55 msgstr ""
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.
63 #, sh-format
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"
68 EOF
70 tmpfiles="$tmpfiles fr.po.new"
71 : ${MSGMERGE=msgmerge}
72 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
74 : ${DIFF=diff}
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
81 : ${MSGFMT=msgfmt}
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
88 [2-9].*) ;;
89 *) rm -fr $tmpfiles; exit 77;;
90 esac
92 # Test which of the fr_FR locales are installed.
93 : ${LOCALE_FR=fr_FR}
94 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
95 if test $LOCALE_FR != none; then
96 LC_ALL=$LOCALE_FR ./testlocale
97 case $? in
98 0) ;;
99 77) LOCALE_FR=none;;
100 *) exit 1;;
101 esac
103 if test $LOCALE_FR_UTF8 != none; then
104 LC_ALL=$LOCALE_FR_UTF8 ./testlocale
105 case $? in
106 0) ;;
107 77) LOCALE_FR_UTF8=none;;
108 *) exit 1;;
109 esac
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.
119 2 morceaux de gateau
121 # Expected result when bash is built with i18n support.
122 cat <<\EOF > prog.ok
123 «Votre commande, s'il vous plait», dit le garçon.
124 2 morceaux de gateau
126 cat <<\EOF > prog.oku
127 «Votre commande, s'il vous plait», dit le garçon.
128 2 morceaux de gateau
131 : ${LOCALE_FR=fr_FR}
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
135 : ${DIFF=diff}
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
141 : ${DIFF=diff}
142 ${DIFF} prog.nok prog.out > /dev/null && { rm -fr $tmpfiles; exit 77; }
143 ${DIFF} prog.oku prog.out || exit 1
146 rm -fr $tmpfiles
148 exit 0