Home | History | Annotate | Line # | Download | only in tests
      1 #! /bin/sh
      2 
      3 # Test of --tcl option.
      4 
      5 tmpfiles=""
      6 trap 'rm -fr $tmpfiles' 1 2 3 15
      7 
      8 # Test whether we can execute Tcl programs and Tcl's fconfigure command
      9 # understands the -encoding option (it does since approximately Tcl 8.1).
     10 tmpfiles="$tmpfiles version.tcl"
     11 cat <<\EOF > version.tcl
     12 fconfigure stdout -encoding utf-8
     13 puts $tcl_version
     14 EOF
     15 (tclsh version.tcl) >/dev/null 2>/dev/null \
     16   || { echo "Skipping test: tclsh not found or Tcl too old"
     17        rm -fr $tmpfiles; exit 77
     18      }
     19 
     20 tmpfiles="$tmpfiles fr.po"
     21 cat <<\EOF > fr.po
     22 msgid ""
     23 msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
     24 
     25 #: program.tcl:5
     26 msgid "'Your command, please?', asked the waiter."
     27 msgstr "Votre commande, s'il vous plait, dit le garon."
     28 
     29 # Reverse the arguments.
     30 #: program.tcl:6
     31 #, tcl-format
     32 msgid "%s is replaced by %s."
     33 msgstr "%2$s remplace %1$s."
     34 EOF
     35 
     36 tmpfiles="$tmpfiles msgs"
     37 test -d msgs || mkdir msgs
     38 
     39 : ${MSGFMT=msgfmt}
     40 ${MSGFMT} --tcl -d msgs -l fr fr.po || exit 1
     41 
     42 tmpfiles="$tmpfiles prog.out"
     43 : ${MSGUNFMT=msgunfmt}
     44 GETTEXTDATADIR=${top_srcdir}/src \
     45 ${MSGUNFMT} --tcl -d msgs -l fr -o prog.out || exit 1
     46 
     47 tmpfiles="$tmpfiles prog.ok"
     48 cat <<\EOF > prog.ok
     49 msgid ""
     50 msgstr "Content-Type: text/plain; charset=UTF-8\n"
     51 
     52 msgid "'Your command, please?', asked the waiter."
     53 msgstr "Votre commande, s'il vous plait, dit le garon."
     54 
     55 msgid "%s is replaced by %s."
     56 msgstr "%2$s remplace %1$s."
     57 EOF
     58 : ${DIFF=diff}
     59 ${DIFF} prog.ok prog.out || exit 1
     60 
     61 rm -fr $tmpfiles
     62 
     63 exit 0
     64