• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test msgfilter on a PO file with contexts.
5
6if (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
14else
15  ac_n= ac_c='\c' ac_t=
16fi
17
18# Some sed programs (Solaris etc.) omit the last line if it ended without
19# a newline. We must skip this test when we encounter such a broken sed.
20sedoutput=`echo $ac_n "abc$ac_c" | sed -e s/x/x/`
21test -n "$sedoutput" || {
22  echo "Skipping test: sed program is broken"
23  Exit 77
24}
25
26# Some sed programs (IRIX, OSF/1 etc.) add a newline to the last line if it
27# doesn't end with a newline.
28sedoutputcount=`echo $ac_n "abc$ac_c" | sed -e s/x/x/ | wc -c`
29sedoutputcount=`echo "$sedoutputcount" | sed -e 's/[ 	]//g'`
30test "$sedoutputcount" = 3 || {
31  echo "Skipping test: sed program inserts extra newline"
32  Exit 77
33}
34
35cat <<\EOF > mfi-test4.po
36msgid ""
37msgstr ""
38"Content-Type: text/plain; charset=UTF-8\n"
39"Content-Transfer-Encoding: 8bit\n"
40
41#. A menu item
42msgctxt "File|"
43msgid "Open"
44msgstr "Ouvrir"
45
46#. A menu item
47msgctxt "File|"
48msgid "New"
49msgstr "Nouveau"
50
51#. Denote a lock's state
52msgctxt "Lock state"
53msgid "Open"
54msgstr "Ouvert"
55
56#. Denote a lock's state
57msgctxt "Lock state"
58msgid "Closed"
59msgstr "Fermé"
60
61#. A product
62msgctxt "Audi"
63msgid "car"
64msgstr "voiture"
65
66#. A product
67msgctxt "Océ"
68msgid "copier"
69msgstr "photocopieur"
70
71#~ msgid "Save As"
72#~ msgstr "Enregistrer l'as"
73
74#. A menu item
75#~ msgctxt "File|"
76#~ msgid "Save As"
77#~ msgstr "Enregistrer sous"
78EOF
79
80: ${MSGFILTER=msgfilter}
81sedexpr1='1{
82s/^/\[\[/
83}'
84sedexpr2='${
85s/$/\]\]/
86}'
87LC_ALL=C \
88${MSGFILTER} -i mfi-test4.po -o mfi-test4.out sed -e "$sedexpr1" -e "$sedexpr2" >mfi-test4.err 2>&1
89result=$?
90cat mfi-test4.err | grep -v 'warning: Locale charset' | grep -v '^ '
91test $result = 0 || { Exit 1; }
92
93cat <<\EOF > mfi-test4.ok
94msgid ""
95msgstr ""
96"[[Content-Type: text/plain; charset=UTF-8\n"
97"Content-Transfer-Encoding: 8bit]]\n"
98
99#. A menu item
100msgctxt "File|"
101msgid "Open"
102msgstr "[[Ouvrir]]"
103
104#. A menu item
105msgctxt "File|"
106msgid "New"
107msgstr "[[Nouveau]]"
108
109#. Denote a lock's state
110msgctxt "Lock state"
111msgid "Open"
112msgstr "[[Ouvert]]"
113
114#. Denote a lock's state
115msgctxt "Lock state"
116msgid "Closed"
117msgstr "[[Fermé]]"
118
119#. A product
120msgctxt "Audi"
121msgid "car"
122msgstr "[[voiture]]"
123
124#. A product
125msgctxt "Océ"
126msgid "copier"
127msgstr "[[photocopieur]]"
128
129#~ msgid "Save As"
130#~ msgstr "[[Enregistrer l'as]]"
131
132#. A menu item
133#~ msgctxt "File|"
134#~ msgid "Save As"
135#~ msgstr "[[Enregistrer sous]]"
136EOF
137
138: ${DIFF=diff}
139${DIFF} mfi-test4.ok mfi-test4.out
140result=$?
141
142exit $result
143