Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / msgexec-4
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test msgexec on a PO file with contexts.
5
6 # This test fails on mingw (in a Cygwin environment), due to the combination
7 # of two reasons:
8 # 1. The value of the environment variable MSGEXEC_MSGCTXT is stored
9 #    in UTF-8 encoding (i.e. the PO file's encoding); it should be stored
10 #    in the GetACP() encoding instead. This problem is inherent in msgexec,
11 #    and msgexec warns about it - but in this test, we filter the warnings
12 #    away.
13 # 2. The child process is Cygwin's sh.exe, and is affected by a Cygwin bug:
14 #    the values returned by getenv() in the child process, when the parent
15 #    process is a mingw program, are in the GetOEMCP() encoding (should be
16 #    in the GetACP() encoding). This has been reported at
17 #    <http://cygwin.com/ml/cygwin/2009-08/msg00430.html>.
18
19 cat <<\EOF > mex-test4.po
20 msgid ""
21 msgstr ""
22 "Content-Type: text/plain; charset=UTF-8\n"
23 "Content-Transfer-Encoding: 8bit\n"
24
25 #. A menu item
26 msgctxt "File|"
27 msgid "Open"
28 msgstr "Ouvrir"
29
30 #. A menu item
31 msgctxt "File|"
32 msgid "New"
33 msgstr "Nouveau"
34
35 #. Denote a lock's state
36 msgctxt "Lock state"
37 msgid "Open"
38 msgstr "Ouvert"
39
40 #. Denote a lock's state
41 msgctxt "Lock state"
42 msgid "Closed"
43 msgstr "Fermé"
44
45 #. A product
46 msgctxt "Audi"
47 msgid "car"
48 msgstr "voiture"
49
50 #. A product
51 msgctxt "Océ"
52 msgid "copier"
53 msgstr "photocopieur"
54
55 #~ msgid "Save As"
56 #~ msgstr "Enregistrer l'as"
57
58 #. A menu item
59 #~ msgctxt "File|"
60 #~ msgid "Save As"
61 #~ msgstr "Enregistrer sous"
62 EOF
63
64 cat <<\EOF > mex-test4.sh
65 #! /bin/sh
66 echo "========================= $MSGEXEC_LOCATION =========================" | LC_ALL=C tr -d '\r'
67 if test -n "${MSGEXEC_MSGCTXT+set}"; then
68   echo "context: $MSGEXEC_MSGCTXT" | LC_ALL=C tr -d '\r'
69 fi
70 cat <<MEOF
71 $MSGEXEC_MSGID
72 ---
73 MEOF
74 cat
75 echo | LC_ALL=C tr -d '\r'
76 exit 0
77 EOF
78 chmod a+x mex-test4.sh
79
80 : ${MSGEXEC=msgexec}
81 LC_ALL=C \
82 ${MSGEXEC} -i mex-test4.po ./mex-test4.sh > mex-test4.out 2> mex-test4.err
83 result=$?
84 cat mex-test4.err | grep -v 'warning: Locale charset' | grep -v '^ '
85 test $result = 0 || { exit 1; }
86
87 cat <<\EOF > mex-test4.ok
88 ========================= mex-test4.po:2 =========================
89
90 ---
91 Content-Type: text/plain; charset=UTF-8
92 Content-Transfer-Encoding: 8bit
93
94 ========================= mex-test4.po:9 =========================
95 context: File|
96 Open
97 ---
98 Ouvrir
99 ========================= mex-test4.po:14 =========================
100 context: File|
101 New
102 ---
103 Nouveau
104 ========================= mex-test4.po:19 =========================
105 context: Lock state
106 Open
107 ---
108 Ouvert
109 ========================= mex-test4.po:24 =========================
110 context: Lock state
111 Closed
112 ---
113 Fermé
114 ========================= mex-test4.po:29 =========================
115 context: Audi
116 car
117 ---
118 voiture
119 ========================= mex-test4.po:34 =========================
120 context: Océ
121 copier
122 ---
123 photocopieur
124 ========================= mex-test4.po:37 =========================
125 Save As
126 ---
127 Enregistrer l'as
128 ========================= mex-test4.po:42 =========================
129 context: File|
130 Save As
131 ---
132 Enregistrer sous
133 EOF
134
135 : ${DIFF=diff}
136 ${DIFF} mex-test4.ok mex-test4.out
137 result=$?
138
139 exit $result