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