2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
11 cat <<\EOF > empty.xml
16 ${XGETTEXT} --itstool -o empty.pot empty.xml 2>empty.err || { cat empty.err; exit 1; }
18 test -d its || mkdir its
20 cat <<\EOF > its/empty-1.loc
25 ${XGETTEXT} --itstool -o empty.pot empty.xml 2>empty.err || { cat empty.err; exit 1; }
27 cat <<\EOF > its/empty-2.loc
30 <locatingRule pattern="*.xml">
31 <documentRule prefix="" localName="empty" target="empty.its"/>
36 ${XGETTEXT} --itstool -o empty.pot empty.xml 2>empty.err || { cat empty.err; exit 1; }
38 cat <<\EOF > its/empty.its
40 <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0">
44 ${XGETTEXT} --itstool -o empty.pot empty.xml 2>empty.err || { cat empty.err; exit 1; }
46 cat <<\EOF > its/messages.loc
49 <locatingRule pattern="*.xml">
50 <documentRule localName="messages" target="messages.its"/>
52 <locatingRule pattern="*.msg">
53 <documentRule localName="messages" target="messages.its"/>
58 cat <<\EOF > its/messages.its
60 <its:rules xmlns:its="http://www.w3.org/2005/11/its"
61 xmlns:gt="https://www.gnu.org/s/gettext/ns/its/extensions/1.0"
62 xmlns:msg="http://www.gnu.org/s/gettext/ns/messages/1.0"
64 <!-- Invalid: no selector -->
65 <its:translateRule translate="yes"/>
66 <!-- Invalid: no translate -->
67 <its:translateRule selector="/"/>
69 <its:translateRule selector="//msg:message/@comment" translate="yes"/>
70 <its:translateRule selector="//msg:note" translate="no"/>
71 <its:translateRule selector="//msg:p[@translatable = 'no']"
74 <!-- Invalid: no selector -->
75 <its:locNoteRule locNoteType="alert"/>
76 <!-- Invalid: no locNoteType -->
77 <its:locNoteRule selector="/"/>
78 <its:locNoteRule selector="//msg:message/*" locNoteType="alert"
79 locNotePointer="../msg:note"/>
80 <its:locNoteRule selector="//msg:code" locNoteType="alert">
81 <its:locNote>This is code</its:locNote>
83 <its:locNoteRule selector="//msg:message/@comment" locNoteType="alert">
84 <its:locNote>This is a comment</its:locNote>
87 <!-- Invalid: no selector -->
88 <its:withinTextRule withinText="yes"/>
89 <!-- Invalid: no withinText -->
90 <its:withinTextRule selector="/"/>
91 <its:withinTextRule selector="//msg:span | //msg:link" withinText="yes"/>
93 <!-- Invalid: no selector -->
94 <its:preserveSpaceRule space="preserve"/>
95 <!-- Invalid: no space -->
96 <its:preserveSpaceRule selector="/"/>
97 <its:preserveSpaceRule selector="//msg:code" space="preserve"/>
99 <gt:contextRule selector="//msg:p[@context = 'yes']"
100 contextPointer="substring-before(., '|')"
101 textPointer="substring-after(., '|')"/>
103 <gt:escapeRule selector="//msg:message/*[@unescape = 'yes']" escape="no"/>
105 <its:translateRule selector="//msg:message/@unescaped" translate="yes"/>
106 <gt:escapeRule selector="//msg:message/@unescaped" escape="no"/>
110 cat <<\EOF >messages.xml
111 <?xml version="1.0"?>
112 <!DOCTYPE messages PUBLIC "" "" [
115 <messages xmlns="http://www.gnu.org/s/gettext/ns/messages/1.0"
116 xmlns:its="http://www.w3.org/2005/11/its">
118 <p>This is a test message &foo;><&""</p>
121 <p its:translate="no">This is a non-translatable message</p>
124 <p>This is a test message, with an <span>element</span> in a <link href="http://www.gnu.org/s/gettext">text</link></p>
127 <code> $ echo ' ' >> /dev/null
132 <message comment="This is a comment <>&"">
133 <p>This is a test message, with an attribute</p>
137 This is a localization note
139 <p>This is a test message, with a localization note</p>
142 <p its:locNote="This is a local localization note" its:locNoteType="alert">
143 This is a test message, with a local localization note
147 <!-- empty element, which shouldn't be extracted -->
151 <p xml:space="preserve"> This is a message with space preserved</p>
154 <p translatable="no">This is a non-translatable string</p>
156 <message its:translate="no">
157 <p>This is a non-translatable string</p>
160 <!-- This is a comment -->
161 <p context="yes">context|A translatable string with a context prefixed</p>
164 <p xml:space="trim"> Leading/trailing whitespaces are removed,
169 <p unescape="yes">This is an unescaped element <>&"</p>
171 <message unescaped="This is an unescaped attribute <>&"">
177 cat <<\EOF >messages.ok
178 #. (itstool) path: message/p
180 msgid "This is a test message &foo;><&\"\""
183 #. (itstool) path: message/p
185 msgid "This is a test message, with an <span>element</span> in a <link href=\"http://www.gnu.org/s/gettext\">text</link>"
189 #. (itstool) path: message/code
193 " $ echo ' ' >> /dev/null\n"
194 " $ cat < /dev/yes\n"
195 " $ sleep 10 &\n"
199 #. (itstool) path: messages/message@comment
201 msgid "This is a comment <>&""
204 #. (itstool) path: message/p
206 msgid "This is a test message, with an attribute"
209 #. This is a localization note
210 #. (itstool) path: message/p
212 msgid "This is a test message, with a localization note"
215 #. This is a local localization note
216 #. (itstool) path: message/p
218 msgid "This is a test message, with a local localization note"
221 #. (itstool) path: message/p
224 msgid " This is a message with space preserved"
228 #. (itstool) path: message/p
231 msgid "A translatable string with a context prefixed"
234 #. (itstool) path: message/p
237 "Leading/trailing whitespaces are removed,\n"
241 #. (itstool) path: message/p
243 msgid "This is an unescaped element <>&\""
246 #. (itstool) path: messages/message@unescaped
248 msgid "This is an unescaped attribute <>&\""
254 ${XGETTEXT} --itstool --no-wrap --omit-header -o messages.pot messages.xml 2>messages.err || { cat messages.err; exit 1; }
255 ${DIFF} messages.ok messages.pot
257 test $result = 0 || exit $result
259 # Check if locating rules can work with --directory, and extra ".in"
260 # file name extension.
261 test -d data || mkdir data
262 test -d po || mkdir po
264 cp messages.xml data/messages.msg.in
268 export GETTEXTDATADIR
270 ${XGETTEXT} --itstool --no-wrap --omit-header --directory=.. -o messages.pot.in data/messages.msg.in 2>messages.err || { cat messages.err; exit 1; }
271 sed -e 's!^#: data/messages.msg.in!#: messages.xml!' \
272 < messages.pot.in > messages.pot
274 ${DIFF} ../messages.ok messages.pot
276 test $result = 0 || exit $result