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