summaryrefslogtreecommitdiffstats
path: root/gettext-tools/tests/msgfmt-13
blob: e7a52f4faea585f963de50a8565efd8605c17e27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /bin/sh

# Test basic functioning with Java .properties syntax.

tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15

tmpfiles="$tmpfiles LC_MESSAGES"
test -d LC_MESSAGES || mkdir LC_MESSAGES

tmpfiles="$tmpfiles module1.properties module2.properties"
cat <<\EOF > module1.properties
SYS_(C)\n=MSGFMT(3) portable message object file compiler\nCopyright (C) 1995 Free Software Foundation\nReport bugs to <bug-gnu-utils@gnu.org>\n
msg\ 1=msg 1 translation
help\ 2\ %d=help 2 translation
error\ 3=error 3 translation
EOF

cat <<\EOF > module2.properties
# ---
mesg\ 4=mesg 4 translation
error\ 3=alternate error 3 translation
error\ 5=error 5 translation
window\ 6=window 6 translation
EOF

# Without use of msgcat, expect a "duplicate message definition" error.
: ${MSGFMT=msgfmt}
if ${MSGFMT} --properties-input module1.properties module2.properties -o LC_MESSAGES/gen.mo 2> /dev/null; then
  rm -fr $tmpfiles
  exit 1
fi

# With msgcat, it should work.
tmpfiles="$tmpfiles modules.properties"
: ${MSGCAT=msgcat} ${MSGFMT=msgfmt}
${MSGCAT} --properties-input --properties-output --use-first module1.properties module2.properties -o modules.properties
test $? = 0 || { rm -fr $tmpfiles; exit 1; }
${MSGFMT} --properties-input modules.properties -o LC_MESSAGES/gen.mo
test $? = 0 || { rm -fr $tmpfiles; exit 1; }

tmpfiles="$tmpfiles mf-test1.out"
: ${GETTEXT=gettext}
TEXTDOMAINDIR=.. LANGUAGE=tests \
${GETTEXT} --env LC_ALL=en gen 'SYS_(C)
' > mf-test1.out

tmpfiles="$tmpfiles gtmf-test1.ok"
cat <<EOF > gtmf-test1.ok
MSGFMT(3) portable message object file compiler
Copyright (C) 1995 Free Software Foundation
Report bugs to <bug-gnu-utils@gnu.org>
EOF

: ${DIFF=diff}
${DIFF} gtmf-test1.ok mf-test1.out
result=$?

rm -fr $tmpfiles

exit $result