No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / lang-tcl
blob93d6fbe373afc8c9114b6e8bbc8293898d103341
1 #! /bin/sh
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 tmpfiles=""
12 trap 'rm -fr $tmpfiles' 1 2 3 15
14 tmpfiles="$tmpfiles program.tcl"
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
24 tmpfiles="$tmpfiles prog.pot"
25 : ${XGETTEXT=xgettext}
26 ${XGETTEXT} -o prog.pot --omit-header -k_ program.tcl
28 tmpfiles="$tmpfiles prog.ok"
29 cat <<EOF > prog.ok
30 #: program.tcl:5
31 msgid "'Your command, please?', asked the waiter."
32 msgstr ""
34 #: program.tcl:6
35 #, tcl-format
36 msgid "%s is replaced by %s."
37 msgstr ""
38 EOF
40 : ${DIFF=diff}
41 ${DIFF} prog.ok prog.pot || exit 1
43 tmpfiles="$tmpfiles fr.po"
44 cat <<\EOF > fr.po
45 msgid ""
46 msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
48 #: program.tcl:5
49 msgid "'Your command, please?', asked the waiter."
50 msgstr "«Votre commande, s'il vous plait», dit le garçon."
52 # Reverse the arguments.
53 #: program.tcl:6
54 #, tcl-format
55 msgid "%s is replaced by %s."
56 msgstr "%2$s remplace %1$s."
57 EOF
59 tmpfiles="$tmpfiles fr.po.new"
60 : ${MSGMERGE=msgmerge}
61 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
63 : ${DIFF=diff}
64 ${DIFF} fr.po fr.po.new || exit 1
66 tmpfiles="$tmpfiles msgs"
67 test -d msgs || mkdir msgs
69 : ${MSGFMT=msgfmt}
70 ${MSGFMT} --tcl -d msgs -l fr fr.po || exit 1
72 # Test for presence of tclsh with msgcat extension.
73 tmpfiles="$tmpfiles version.tcl"
74 cat <<\EOF > version.tcl
75 package require msgcat
76 puts $tcl_version
77 EOF
78 (tclsh version.tcl) >/dev/null 2>/dev/null \
79 || { rm -fr $tmpfiles; exit 77; }
81 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
82 : ${DIFF=diff}
83 cat <<\EOF > prog.ok
84 «Votre commande, s'il vous plait», dit le garçon.
85 EUR remplace FF.
86 EOF
87 cat <<\EOF > prog.oku
88 «Votre commande, s'il vous plait», dit le garçon.
89 EUR remplace FF.
90 EOF
92 : ${LOCALE_FR=fr_FR}
93 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
94 if test $LOCALE_FR != none; then
95 LANGUAGE= LANG=$LOCALE_FR LC_MESSAGES= LC_CTYPE= LC_ALL= tclsh program.tcl > prog.out || exit 1
96 ${DIFF} prog.ok prog.out || exit 1
98 if test $LOCALE_FR_UTF8 != none; then
99 LANGUAGE= LANG=$LOCALE_FR_UTF8 LC_MESSAGES= LC_CTYPE= LC_ALL= tclsh program.tcl > prog.out || exit 1
100 ${DIFF} prog.oku prog.out || exit 1
102 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
103 rm -fr $tmpfiles; exit 77
106 rm -fr $tmpfiles
108 exit 0