• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/tests/
1#! /bin/sh
2
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.
6
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 "".
10
11tmpfiles=""
12trap 'rm -fr $tmpfiles' 1 2 3 15
13
14tmpfiles="$tmpfiles program.tcl"
15cat <<\EOF > program.tcl
16#!/usr/bin/env tclsh
17package require msgcat
18::msgcat::mcload [file join [file dirname [info script]] msgs]
19proc _ {s} {return [::msgcat::mc $s]}
20puts [_ "'Your command, please?', asked the waiter."]
21puts [format [::msgcat::mc "%s is replaced by %s."] "FF" "EUR"]
22EOF
23
24tmpfiles="$tmpfiles prog.tmp prog.pot"
25: ${XGETTEXT=xgettext}
26${XGETTEXT} -o prog.tmp --omit-header -k_ program.tcl
27test $? = 0 || { rm -fr $tmpfiles; exit 1; }
28tr -d '\r' < prog.tmp > prog.pot
29test $? = 0 || { rm -fr $tmpfiles; exit 1; }
30
31tmpfiles="$tmpfiles prog.ok"
32cat <<EOF > prog.ok
33#: program.tcl:5
34msgid "'Your command, please?', asked the waiter."
35msgstr ""
36
37#: program.tcl:6
38#, tcl-format
39msgid "%s is replaced by %s."
40msgstr ""
41EOF
42
43: ${DIFF=diff}
44${DIFF} prog.ok prog.pot || exit 1
45
46tmpfiles="$tmpfiles fr.po"
47cat <<\EOF > fr.po
48msgid ""
49msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
50
51#: program.tcl:5
52msgid "'Your command, please?', asked the waiter."
53msgstr "�Votre commande, s'il vous plait�, dit le gar�on."
54
55# Reverse the arguments.
56#: program.tcl:6
57#, tcl-format
58msgid "%s is replaced by %s."
59msgstr "%2$s remplace %1$s."
60EOF
61
62tmpfiles="$tmpfiles fr.po.tmp fr.po.new"
63: ${MSGMERGE=msgmerge}
64${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot
65test $? = 0 || { rm -fr $tmpfiles; exit 1; }
66tr -d '\r' < fr.po.tmp > fr.po.new
67test $? = 0 || { rm -fr $tmpfiles; exit 1; }
68
69: ${DIFF=diff}
70${DIFF} fr.po fr.po.new || exit 1
71
72tmpfiles="$tmpfiles msgs"
73test -d msgs || mkdir msgs
74
75: ${MSGFMT=msgfmt}
76${MSGFMT} --tcl -d msgs -l fr fr.po || exit 1
77
78# Test for presence of tclsh with msgcat extension.
79tmpfiles="$tmpfiles version.tcl"
80cat <<\EOF > version.tcl
81package require msgcat
82puts $tcl_version
83EOF
84(tclsh version.tcl) >/dev/null 2>/dev/null \
85  || { echo "Skipping test: tclsh not found or msgcat extension not present"
86       rm -fr $tmpfiles; exit 77
87     }
88
89tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
90: ${DIFF=diff}
91cat <<\EOF > prog.ok
92Votre commande, s'il vous plait�, dit le gar�on.
93EUR remplace FF.
94EOF
95cat <<\EOF > prog.oku
96��Votre commande, s'il vous plait��, dit le gar��on.
97EUR remplace FF.
98EOF
99
100: ${LOCALE_FR=fr_FR}
101: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
102if test $LOCALE_FR != none; then
103  LANGUAGE= LANG=$LOCALE_FR LC_MESSAGES= LC_CTYPE= LC_ALL= tclsh program.tcl > prog.out || exit 1
104  ${DIFF} prog.ok prog.out || exit 1
105fi
106if test $LOCALE_FR_UTF8 != none; then
107  LANGUAGE= LANG=$LOCALE_FR_UTF8 LC_MESSAGES= LC_CTYPE= LC_ALL= tclsh program.tcl > prog.out || exit 1
108  ${DIFF} prog.oku prog.out || exit 1
109fi
110if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
111  if test -f /usr/bin/localedef; then
112    echo "Skipping test: no french locale is installed"
113  else
114    echo "Skipping test: no french locale is supported"
115  fi
116  rm -fr $tmpfiles; exit 77
117fi
118
119rm -fr $tmpfiles
120
121exit 0
122