Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / tests / msgunfmt-tcl-1
1 #! /bin/sh
2
3 # Test of --tcl option.
4
5 # This test fails on mingw, in the Cygwin environment: tclsh exists as
6 # tclsh.exe from Cygwin. When msgunfmt invokes it, it crashes, presenting
7 # a dialog "16 bit MS-DOS subsystem - The NTVDM CPU has encountered an
8 # illegal instruction." When this dialog is closed, msgunfmt continues,
9 # reads empty output, and refrains from creating a PO file because
10 # --force-po was not specified.
11
12 tmpfiles=""
13 trap 'rm -fr $tmpfiles' 1 2 3 15
14
15 # Test whether we can execute Tcl programs and Tcl's fconfigure command
16 # understands the -encoding option (it does since approximately Tcl 8.1).
17 tmpfiles="$tmpfiles version.tcl"
18 cat <<\EOF > version.tcl
19 fconfigure stdout -encoding utf-8
20 puts $tcl_version
21 EOF
22 (tclsh version.tcl) >/dev/null 2>/dev/null \
23   || { echo "Skipping test: tclsh not found or Tcl too old"
24        rm -fr $tmpfiles; exit 77
25      }
26
27 tmpfiles="$tmpfiles fr.po"
28 cat <<\EOF > fr.po
29 msgid ""
30 msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
31
32 #: program.tcl:5
33 msgid "'Your command, please?', asked the waiter."
34 msgstr "«Votre commande, s'il vous plait», dit le garçon."
35
36 # Reverse the arguments.
37 #: program.tcl:6
38 #, tcl-format
39 msgid "%s is replaced by %s."
40 msgstr "%2$s remplace %1$s."
41 EOF
42
43 tmpfiles="$tmpfiles msgs"
44 test -d msgs || mkdir msgs
45
46 : ${MSGFMT=msgfmt}
47 ${MSGFMT} --tcl -d msgs -l fr fr.po || exit 1
48
49 tmpfiles="$tmpfiles prog.out"
50 : ${MSGUNFMT=msgunfmt}
51 GETTEXTDATADIR=${top_srcdir}/src \
52 ${MSGUNFMT} --tcl -d msgs -l fr -o prog.out || exit 1
53
54 tmpfiles="$tmpfiles prog.ok"
55 cat <<\EOF > prog.ok
56 msgid ""
57 msgstr "Content-Type: text/plain; charset=UTF-8\n"
58
59 msgid "'Your command, please?', asked the waiter."
60 msgstr "«Votre commande, s'il vous plait», dit le garçon."
61
62 msgid "%s is replaced by %s."
63 msgstr "%2$s remplace %1$s."
64 EOF
65 : ${DIFF=diff}
66 ${DIFF} prog.ok prog.out || exit 1
67
68 rm -fr $tmpfiles
69
70 exit 0