2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test of gettext facilities in the JavaScript language.
5 # Assumes an fr_FR locale is installed.
6 # Assumes the following packages are installed: gjs.
9 const Format = imports.format;
10 const Gettext = imports.gettext;
12 String.prototype.format = Format.format;
13 const _ = Gettext.gettext;
15 Gettext.textdomain ("prog");
16 Gettext.bindtextdomain ("prog", ".");
17 print(_("'Your command, please?', asked the waiter."));
18 print(_("%s is replaced by %s.").format("FF", "EUR"));
21 : ${XGETTEXT=xgettext}
22 ${XGETTEXT} -o prog.tmp --omit-header --no-location prog.js || exit 1
23 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || exit 1
26 msgid "'Your command, please?', asked the waiter."
30 msgid "%s is replaced by %s."
35 ${DIFF} prog.ok prog.pot || exit 1
39 msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
41 msgid "'Your command, please?', asked the waiter."
42 msgstr "«Votre commande, s'il vous plait», dit le garçon."
44 # Reverse the arguments.
46 msgid "%s is replaced by %s."
47 msgstr "%s remplace %s."
50 : ${MSGMERGE=msgmerge}
51 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || exit 1
52 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || exit 1
55 ${DIFF} fr.po fr.po.new || exit 1
57 test -d fr || mkdir fr
58 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
61 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
63 # Test for presence of gjs.
64 (gjs -h) >/dev/null 2>/dev/null \
65 || { echo "Skipping test: gjs not found"; exit 77; }
66 (gjs -c imports.gettext) >/dev/null 2>/dev/null \
67 || { echo "Skipping test: gjs gettext module not found"; exit 77; }
68 (gjs -c imports.format) >/dev/null 2>/dev/null \
69 || { echo "Skipping test: gjs format module not found"; exit 77; }
71 # Test which of the fr_FR locales are installed.
73 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
74 if test $LOCALE_FR != none; then
75 LC_ALL=$LOCALE_FR ../testlocale
82 if test $LOCALE_FR_UTF8 != none; then
83 LC_ALL=$LOCALE_FR_UTF8 ../testlocale
86 77) LOCALE_FR_UTF8=none;;
90 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
91 if test -f /usr/bin/localedef; then
92 echo "Skipping test: no french locale is installed"
94 echo "Skipping test: no french locale is supported"
101 «Votre commande, s'il vous plait», dit le garçon.
104 cat <<\EOF > prog.oku
105 «Votre commande, s'il vous plait», dit le garçon.
110 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
111 if test $LOCALE_FR != none; then
112 prepare_locale_ fr $LOCALE_FR
113 LANGUAGE= LC_ALL=$LOCALE_FR gjs prog.js > prog.out || exit 1
114 ${DIFF} prog.ok prog.out || exit 1
116 if test $LOCALE_FR_UTF8 != none; then
117 prepare_locale_ fr $LOCALE_FR_UTF8
118 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 gjs prog.js > prog.out || exit 1
119 ${DIFF} -u prog.oku prog.out || exit 1