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 "".
12 trap 'rm -fr $tmpfiles' 1 2 3 15
14 tmpfiles
="$tmpfiles program.tcl"
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 tmpfiles
="$tmpfiles prog.pot"
25 : ${XGETTEXT=xgettext}
26 ${XGETTEXT} -o prog.pot
--omit-header -k_ program.tcl
28 tmpfiles
="$tmpfiles prog.ok"
31 msgid "'Your command, please?', asked the waiter."
36 msgid "%s is replaced by %s."
41 ${DIFF} prog.ok prog.pot ||
exit 1
43 tmpfiles
="$tmpfiles fr.po"
46 msgstr
"Content-Type: text/plain; charset=ISO-8859-1\n"
49 msgid
"'Your command, please?', asked the waiter."
50 msgstr
"«Votre commande, s'il vous plait», dit le garçon."
52 # Reverse the arguments.
55 msgid
"%s is replaced by %s."
56 msgstr
"%2$s remplace %1$s."
59 tmpfiles
="$tmpfiles fr.po.new"
60 : ${MSGMERGE=msgmerge}
61 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
64 ${DIFF} fr.po fr.po.new ||
exit 1
66 tmpfiles
="$tmpfiles msgs"
67 test -d msgs || mkdir msgs
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
78 (tclsh version.tcl
) >/dev
/null
2>/dev
/null \
79 ||
{ rm -fr $tmpfiles; exit 77; }
81 tmpfiles
="$tmpfiles prog.ok prog.oku prog.out"
84 «Votre commande
, s
'il vous plait», dit le garçon.
88 «Votre commande, s'il vous plait»
, dit le garçon.
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