2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test of gettext facilities in the Tcl language.
5 # Assumes an fr_FR locale is installed.
6 # Assumes the following packages are installed: tcl.
8 # Note: This test fails on MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale
9 # but not in the fr_FR.UTF-8 locale. Probably because in the fr_FR locale,
10 # nl_langinfo(CODESET) returns "".
12 # Note: This test fails on Cygwin 1.7.2 in the fr_FR.UTF-8 locale but not
13 # in the fr_FR.ISO-8859-1 locale.
15 cat <<\EOF > program.tcl
17 package require msgcat
18 ::msgcat::mcload [file join [file dirname [info script]] . msgs]
19 proc _ {s} {return [::msgcat::mc $s]}
20 puts [_ "'Your command, please?', asked the waiter."]
21 puts [format [::msgcat::mc "%s is replaced by %s."] "FF" "EUR"]
24 : ${XGETTEXT=xgettext}
25 ${XGETTEXT} -o prog.tmp --omit-header -k_ program.tcl || exit 1
26 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || exit 1
30 msgid "'Your command, please?', asked the waiter."
35 msgid "%s is replaced by %s."
40 ${DIFF} prog.ok prog.pot || exit 1
44 msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
47 msgid "'Your command, please?', asked the waiter."
48 msgstr "«Votre commande, s'il vous plait», dit le garçon."
50 # Reverse the arguments.
53 msgid "%s is replaced by %s."
54 msgstr "%2$s remplace %1$s."
57 : ${MSGMERGE=msgmerge}
58 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || exit 1
59 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || exit 1
62 ${DIFF} fr.po fr.po.new || exit 1
64 test -d msgs || mkdir msgs
67 ${MSGFMT} --tcl -d msgs -l fr fr.po || exit 1
69 # Test for presence of tclsh with msgcat extension.
70 cat <<\EOF > version.tcl
71 package require msgcat
74 (tclsh version.tcl) >/dev/null 2>/dev/null \
75 || { echo "Skipping test: tclsh not found or msgcat extension not present"
81 «Votre commande, s'il vous plait», dit le garçon.
85 «Votre commande, s'il vous plait», dit le garçon.
90 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
91 if test $LOCALE_FR != none; then
92 prepare_locale_ fr $LOCALE_FR
93 LANGUAGE= LANG=$LOCALE_FR LC_MESSAGES= LC_CTYPE= LC_ALL= tclsh program.tcl > prog.tmp || exit 1
94 LC_ALL=C tr -d '\r' < prog.tmp > prog.out || exit 1
95 ${DIFF} prog.ok prog.out || exit 1
97 if test $LOCALE_FR_UTF8 != none; then
98 prepare_locale_ fr $LOCALE_FR_UTF8
99 LANGUAGE= LANG=$LOCALE_FR_UTF8 LC_MESSAGES= LC_CTYPE= LC_ALL= tclsh program.tcl > prog.tmp || exit 1
100 LC_ALL=C tr -d '\r' < prog.tmp > prog.out || exit 1
101 ${DIFF} prog.oku prog.out || exit 1
103 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
104 if test -f /usr/bin/localedef; then
105 echo "Skipping test: no french locale is installed"
107 echo "Skipping test: no french locale is supported"