Home | History | Annotate | Line # | Download | only in tests
      1 #! /bin/sh
      2 
      3 # Test basic functionality, duplicate detection, multiple domains.
      4 
      5 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
      6   # Stardent Vistra SVR4 grep lacks -e, says ghazi (at] caip.rutgers.edu.
      7   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
      8     ac_n= ac_c='
      9 ' ac_t='        '
     10   else
     11     ac_n=-n ac_c= ac_t=
     12   fi
     13 else
     14   ac_n= ac_c='\c' ac_t=
     15 fi
     16 
     17 tmpfiles=""
     18 trap 'rm -fr $tmpfiles' 1 2 3 15
     19 
     20 tmpfiles="$tmpfiles LC_MESSAGES"
     21 test -d LC_MESSAGES || mkdir LC_MESSAGES
     22 
     23 tmpfiles="$tmpfiles module1.po module2.po"
     24 cat <<EOF > module1.po
     25 #default domain "messages.mo"
     26 msgid	"SYS_(C)\n"
     27 msgstr "MSGFMT(3) portable message object file compiler\n"
     28 "Copyright (C) 1995 Free Software Foundation\n"
     29 "Report bugs to <bug-gnu-utils (at] gnu.org>\n"
     30 msgid	"msg 1"
     31 msgstr	"msg 1 translation"
     32 #
     33 domain	"help_dom"
     34 msgid	"help 2 %d"
     35 msgstr	"help 2 translation"
     36 #
     37 domain	"error_dom"
     38 msgid	"error 3"
     39 msgstr	"error 3 translation"
     40 EOF
     41 
     42 cat <<EOF > module2.po
     43 # ---
     44 #default domain "messages.mo"
     45 msgid	"mesg 4"
     46 msgstr	"mesg 4 translation"
     47 #
     48 domain	"error_dom"
     49 msgid	"error 3"
     50 msgstr	"alternate error 3 translation"
     51 msgid	"error 5"
     52 msgstr	"error 5 translation"
     53 #
     54 domain	"window_dom"
     55 msgid	"window 6"
     56 msgstr	"window 6 translation"
     57 EOF
     58 
     59 # Without use of msgcat, expect a "duplicate message definition" error.
     60 : ${MSGFMT=msgfmt}
     61 if ${MSGFMT} -o LC_MESSAGES/gen.mo module1.po module2.po 2> /dev/null; then
     62   rm -fr $tmpfiles
     63   exit 1
     64 fi
     65 
     66 # With msgcat, it should work.
     67 tmpfiles="$tmpfiles modules.po"
     68 : ${MSGCAT=msgcat} ${MSGFMT=msgfmt}
     69 ${MSGCAT} --use-first -o modules.po module1.po module2.po
     70 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
     71 ${MSGFMT} -o LC_MESSAGES/gen.mo modules.po
     72 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
     73 
     74 tmpfiles="$tmpfiles mf-test2.out"
     75 : ${GETTEXT=gettext}
     76 TEXTDOMAINDIR=.. LANGUAGE=tests \
     77 ${GETTEXT} --env LC_ALL=en gen 'error 3' > mf-test2.out
     78 
     79 tmpfiles="$tmpfiles gtmf-test2.ok"
     80 echo $ac_n "error 3 translation$ac_c" > gtmf-test2.ok
     81 
     82 : ${DIFF=diff}
     83 ${DIFF} gtmf-test2.ok mf-test2.out
     84 result=$?
     85 
     86 rm -fr $tmpfiles
     87 
     88 exit $result
     89