lang-sh revision 1.1 1 #! /bin/sh
2
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.
6
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.
9
10 tmpfiles=""
11 trap 'rm -fr $tmpfiles' 1 2 3 15
12
13 tmpfiles="$tmpfiles prog.sh"
14 cat <<\EOF > prog.sh
15 #! /bin/sh
16
17 n=$1
18
19 . gettext.sh
20
21 TEXTDOMAIN=prog
22 export TEXTDOMAIN
23 TEXTDOMAINDIR=.
24 export TEXTDOMAINDIR
25
26 $echo "`gettext \"'Your command, please?', asked the waiter.\"`"
27
28 $echo "`eval_ngettext \"a piece of cake\" \"\\$n pieces of cake\" $n`"
29 EOF
30
31 tmpfiles="$tmpfiles prog.pot"
32 : ${XGETTEXT=xgettext}
33 ${XGETTEXT} -o prog.pot --omit-header --no-location prog.sh
34
35 tmpfiles="$tmpfiles prog.ok"
36 cat <<\EOF > prog.ok
37 msgid "'Your command, please?', asked the waiter."
38 msgstr ""
39
40 #, sh-format
41 msgid "a piece of cake"
42 msgid_plural "$n pieces of cake"
43 msgstr[0] ""
44 msgstr[1] ""
45 EOF
46
47 : ${DIFF=diff}
48 ${DIFF} prog.ok prog.pot || exit 1
49
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"
56
57 msgid "'Your command, please?', asked the waiter."
58 msgstr "Votre commande, s'il vous plait, dit le garon."
59
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
67
68 tmpfiles="$tmpfiles fr.po.new"
69 : ${MSGMERGE=msgmerge}
70 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
71
72 : ${DIFF=diff}
73 ${DIFF} fr.po fr.po.new || exit 1
74
75 tmpfiles="$tmpfiles fr"
76 test -d fr || mkdir fr
77 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
78
79 : ${MSGFMT=msgfmt}
80 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
81
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
92 fi
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
100 fi
101 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
102 if test -f /usr/bin/localedef; then
103 echo "Skipping test: no french locale is installed"
104 else
105 echo "Skipping test: no french locale is supported"
106 fi
107 rm -fr $tmpfiles; exit 77
108 fi
109
110 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
111 : ${DIFF=diff}
112 cat <<\EOF > prog.ok
113 Votre commande, s'il vous plait, dit le garon.
114 2 morceaux de gateau
115 EOF
116 cat <<\EOF > prog.oku
117 Votre commande, s'il vous plait, dit le garon.
118 2 morceaux de gateau
119 EOF
120
121 : ${LOCALE_FR=fr_FR}
122 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
123 if test $LOCALE_FR != none; then
124 LANGUAGE= LC_ALL=$LOCALE_FR sh ./prog.sh 2 > prog.out || exit 1
125 ${DIFF} prog.ok prog.out || exit 1
126 fi
127 if test $LOCALE_FR_UTF8 != none; then
128 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 sh ./prog.sh 2 > prog.out || exit 1
129 ${DIFF} prog.oku prog.out || exit 1
130 fi
131
132 rm -fr $tmpfiles
133
134 exit 0
135