1#! /bin/sh 2. "${srcdir=.}/init.sh"; path_prepend_ . ../src 3 4# Test of gettext facilities in the Tcl language. 5# Assumes an fr_FR locale is installed. 6# Assumes the following packages are installed: tcl. 7 8# Note: This test fails on MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale 9# but not in the fr_FR.UTF-8 locale. Probably because in the fr_FR locale, 10# nl_langinfo(CODESET) returns "". 11 12# Note: This test fails on Cygwin 1.7.2 in the fr_FR.UTF-8 locale but not 13# in the fr_FR.ISO-8859-1 locale. 14 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 24: ${XGETTEXT=xgettext} 25${XGETTEXT} -o prog.tmp --omit-header -k_ program.tcl || Exit 1 26LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || Exit 1 27 28cat <<EOF > prog.ok 29#: program.tcl:5 30msgid "'Your command, please?', asked the waiter." 31msgstr "" 32 33#: program.tcl:6 34#, tcl-format 35msgid "%s is replaced by %s." 36msgstr "" 37EOF 38 39: ${DIFF=diff} 40${DIFF} prog.ok prog.pot || Exit 1 41 42cat <<\EOF > fr.po 43msgid "" 44msgstr "Content-Type: text/plain; charset=ISO-8859-1\n" 45 46#: program.tcl:5 47msgid "'Your command, please?', asked the waiter." 48msgstr "�Votre commande, s'il vous plait�, dit le gar�on." 49 50# Reverse the arguments. 51#: program.tcl:6 52#, tcl-format 53msgid "%s is replaced by %s." 54msgstr "%2$s remplace %1$s." 55EOF 56 57: ${MSGMERGE=msgmerge} 58${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || Exit 1 59LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || Exit 1 60 61: ${DIFF=diff} 62${DIFF} fr.po fr.po.new || Exit 1 63 64test -d msgs || mkdir msgs 65 66: ${MSGFMT=msgfmt} 67${MSGFMT} --tcl -d msgs -l fr fr.po || Exit 1 68 69# Test for presence of tclsh with msgcat extension. 70cat <<\EOF > version.tcl 71package require msgcat 72puts $tcl_version 73EOF 74(tclsh version.tcl) >/dev/null 2>/dev/null \ 75 || { echo "Skipping test: tclsh not found or msgcat extension not present" 76 Exit 77 77 } 78 79: ${DIFF=diff} 80cat <<\EOF > prog.ok 81�Votre commande, s'il vous plait�, dit le gar�on. 82EUR remplace FF. 83EOF 84cat <<\EOF > prog.oku 85«Votre commande, s'il vous plait», dit le garçon. 86EUR remplace FF. 87EOF 88 89: ${LOCALE_FR=fr_FR} 90: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 91if test $LOCALE_FR != none; then 92 prepare_locale_ fr $LOCALE_FR 93 LANGUAGE= LANG=$LOCALE_FR LC_MESSAGES= LC_CTYPE= LC_ALL= tclsh program.tcl > prog.tmp || Exit 1 94 LC_ALL=C tr -d '\r' < prog.tmp > prog.out || Exit 1 95 ${DIFF} prog.ok prog.out || Exit 1 96fi 97if test $LOCALE_FR_UTF8 != none; then 98 prepare_locale_ fr $LOCALE_FR_UTF8 99 LANGUAGE= LANG=$LOCALE_FR_UTF8 LC_MESSAGES= LC_CTYPE= LC_ALL= tclsh program.tcl > prog.tmp || Exit 1 100 LC_ALL=C tr -d '\r' < prog.tmp > prog.out || Exit 1 101 ${DIFF} prog.oku prog.out || Exit 1 102fi 103if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then 104 if test -f /usr/bin/localedef; then 105 echo "Skipping test: no french locale is installed" 106 else 107 echo "Skipping test: no french locale is supported" 108 fi 109 Exit 77 110fi 111 112Exit 0 113