Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / lang-tcl
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
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.
7
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 "".
11
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.
14
15 cat <<\EOF > program.tcl
16 #!/usr/bin/env tclsh
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"]
22 EOF
23
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
27
28 cat <<EOF > prog.ok
29 #: program.tcl:5
30 msgid "'Your command, please?', asked the waiter."
31 msgstr ""
32
33 #: program.tcl:6
34 #, tcl-format
35 msgid "%s is replaced by %s."
36 msgstr ""
37 EOF
38
39 : ${DIFF=diff}
40 ${DIFF} prog.ok prog.pot || exit 1
41
42 cat <<\EOF > fr.po
43 msgid ""
44 msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
45
46 #: program.tcl:5
47 msgid "'Your command, please?', asked the waiter."
48 msgstr "«Votre commande, s'il vous plait», dit le garçon."
49
50 # Reverse the arguments.
51 #: program.tcl:6
52 #, tcl-format
53 msgid "%s is replaced by %s."
54 msgstr "%2$s remplace %1$s."
55 EOF
56
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
60
61 : ${DIFF=diff}
62 ${DIFF} fr.po fr.po.new || exit 1
63
64 test -d msgs || mkdir msgs
65
66 : ${MSGFMT=msgfmt}
67 ${MSGFMT} --tcl -d msgs -l fr fr.po || exit 1
68
69 # Test for presence of tclsh with msgcat extension.
70 cat <<\EOF > version.tcl
71 package require msgcat
72 puts $tcl_version
73 EOF
74 (tclsh version.tcl) >/dev/null 2>/dev/null \
75   || { echo "Skipping test: tclsh not found or msgcat extension not present"
76        exit 77
77      }
78
79 : ${DIFF=diff}
80 cat <<\EOF > prog.ok
81 «Votre commande, s'il vous plait», dit le garçon.
82 EUR remplace FF.
83 EOF
84 cat <<\EOF > prog.oku
85 «Votre commande, s'il vous plait», dit le garçon.
86 EUR remplace FF.
87 EOF
88
89 : ${LOCALE_FR=fr_FR}
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
96 fi
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
102 fi
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"
106   else
107     echo "Skipping test: no french locale is supported"
108   fi
109   exit 77
110 fi
111
112 exit 0