3 # Test of gettext facilities in the Tcl language.
4 # Assumes an fr_FR locale is installed.
5 # Assumes the following packages are installed: tcl.
7 # Note: This test fails on MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale
8 # but not in the fr_FR.UTF-8 locale. Probably because in the fr_FR locale,
9 # nl_langinfo(CODESET) returns "".
11 # Note: This test fails on Cygwin 1.7.2 in the fr_FR.UTF-8 locale but not
12 # in the fr_FR.ISO-8859-1 locale.
15 trap 'rm -fr $tmpfiles' 1 2 3 15
17 tmpfiles="$tmpfiles program.tcl"
18 cat <<\EOF > program.tcl
20 package require msgcat
21 ::msgcat::mcload [file join [file dirname [info script]] msgs]
22 proc _ {s} {return [::msgcat::mc $s]}
23 puts [_ "'Your command, please?', asked the waiter."]
24 puts [format [::msgcat::mc "%s is replaced by %s."] "FF" "EUR"]
27 tmpfiles="$tmpfiles prog.tmp prog.pot"
28 : ${XGETTEXT=xgettext}
29 ${XGETTEXT} -o prog.tmp --omit-header -k_ program.tcl
30 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
31 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot
32 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
34 tmpfiles="$tmpfiles prog.ok"
37 msgid "'Your command, please?', asked the waiter."
42 msgid "%s is replaced by %s."
47 ${DIFF} prog.ok prog.pot || exit 1
49 tmpfiles="$tmpfiles fr.po"
52 msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
55 msgid "'Your command, please?', asked the waiter."
56 msgstr "«Votre commande, s'il vous plait», dit le garçon."
58 # Reverse the arguments.
61 msgid "%s is replaced by %s."
62 msgstr "%2$s remplace %1$s."
65 tmpfiles="$tmpfiles fr.po.tmp fr.po.new"
66 : ${MSGMERGE=msgmerge}
67 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot
68 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
69 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new
70 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
73 ${DIFF} fr.po fr.po.new || exit 1
75 tmpfiles="$tmpfiles msgs"
76 test -d msgs || mkdir msgs
79 ${MSGFMT} --tcl -d msgs -l fr fr.po || exit 1
81 # Test for presence of tclsh with msgcat extension.
82 tmpfiles="$tmpfiles version.tcl"
83 cat <<\EOF > version.tcl
84 package require msgcat
87 (tclsh version.tcl) >/dev/null 2>/dev/null \
88 || { echo "Skipping test: tclsh not found or msgcat extension not present"
89 rm -fr $tmpfiles; exit 77
92 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
95 «Votre commande, s'il vous plait», dit le garçon.
99 «Votre commande, s'il vous plait», dit le garçon.
104 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
105 if test $LOCALE_FR != none; then
106 LANGUAGE= LANG=$LOCALE_FR LC_MESSAGES= LC_CTYPE= LC_ALL= tclsh program.tcl > prog.tmp || exit 1
107 LC_ALL=C tr -d '\r' < prog.tmp > prog.out || exit 1
108 ${DIFF} prog.ok prog.out || exit 1
110 if test $LOCALE_FR_UTF8 != none; then
111 LANGUAGE= LANG=$LOCALE_FR_UTF8 LC_MESSAGES= LC_CTYPE= LC_ALL= tclsh program.tcl > prog.tmp || exit 1
112 LC_ALL=C tr -d '\r' < prog.tmp > prog.out || exit 1
113 ${DIFF} prog.oku prog.out || exit 1
115 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
116 if test -f /usr/bin/localedef; then
117 echo "Skipping test: no french locale is installed"
119 echo "Skipping test: no french locale is supported"
121 rm -fr $tmpfiles; exit 77