2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test of gettext facilities in the Lua language.
5 # Assumes an fr_FR locale is installed.
6 # Assumes the following packages are installed: lua, lua-gettext.
10 gettext.bindtextdomain("prog", ".")
11 gettext.textdomain("prog")
15 print(gettext.gettext("'Your command, please?', asked the waiter."))
16 print(string.format(gettext.ngettext('a piece of cake', [[%d pieces of cake]], n), n))
17 print(string.format(_[==[%s is replaced by %s.]==], "FF", "EUR"))
20 : ${XGETTEXT=xgettext}
21 ${XGETTEXT} -o prog.tmp --omit-header --no-location prog.lua || exit 1
22 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || exit 1
25 msgid "'Your command, please?', asked the waiter."
29 msgid "a piece of cake"
30 msgid_plural "%d pieces of cake"
35 msgid "%s is replaced by %s."
40 ${DIFF} prog.ok prog.pot || exit 1
45 "Content-Type: text/plain; charset=ISO-8859-1\n"
46 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
48 msgid "'Your command, please?', asked the waiter."
49 msgstr "«Votre commande, s'il vous plait», dit le garçon."
52 msgid "a piece of cake"
53 msgid_plural "%d pieces of cake"
54 msgstr[0] "un morceau de gateau"
55 msgstr[1] "%d morceaux de gateau"
58 msgid "%s is replaced by %s."
59 msgstr "%s remplace %s."
62 : ${MSGMERGE=msgmerge}
63 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || exit 1
64 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || exit 1
67 ${DIFF} fr.po fr.po.new || exit 1
69 test -d fr || mkdir fr
70 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
73 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
75 # Test for presence of lua version 5.0 or newer with gettext support.
76 (lua -v) >/dev/null 2>/dev/null
78 || { echo "Skipping test: lua not found"; exit 77; }
79 case `lua -v 2>&1 | sed -e 's/^[^0-9]*//'` in
81 *) echo "Skipping test: lua version too old"; exit 77;;
83 { lua -v -l gettext > /dev/null 2>/dev/null; } \
84 || { echo "Skipping test: lua gettext module not found"
88 # Test which of the fr_FR locales are installed.
90 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
91 if test $LOCALE_FR != none; then
92 LC_ALL=$LOCALE_FR ../testlocale
99 if test $LOCALE_FR_UTF8 != none; then
100 LC_ALL=$LOCALE_FR_UTF8 ../testlocale
103 77) LOCALE_FR_UTF8=none;;
107 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
108 if test -f /usr/bin/localedef; then
109 echo "Skipping test: no french locale is installed"
111 echo "Skipping test: no french locale is supported"
118 «Votre commande, s'il vous plait», dit le garçon.
119 42 morceaux de gateau
122 cat <<\EOF > prog.oku
123 «Votre commande, s'il vous plait», dit le garçon.
124 42 morceaux de gateau
129 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
130 if test $LOCALE_FR != none; then
131 prepare_locale_ fr $LOCALE_FR
132 LANGUAGE= LC_ALL=$LOCALE_FR lua -l gettext prog.lua > prog.out || exit 1
133 ${DIFF} prog.ok prog.out || exit 1
135 if test $LOCALE_FR_UTF8 != none; then
136 prepare_locale_ fr $LOCALE_FR_UTF8
137 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 lua -l gettext prog.lua > prog.out || exit 1
138 ${DIFF} prog.oku prog.out || exit 1