mirror of
https://https.git.savannah.gnu.org/git/gettext.git
synced 2026-01-26 15:39:11 +00:00
tests: Add tests for ITS support
This commit is contained in:
parent
3d5aac5a55
commit
cf3a0b051c
@ -113,6 +113,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \
|
||||
xgettext-vala-1 \
|
||||
xgettext-gsettings-1 \
|
||||
xgettext-desktop-1 \
|
||||
xgettext-its-1 \
|
||||
format-awk-1 format-awk-2 \
|
||||
format-boost-1 format-boost-2 \
|
||||
format-c-1 format-c-2 format-c-3 format-c-4 format-c-5 \
|
||||
|
||||
132
gettext-tools/tests/xgettext-its-1
Executable file
132
gettext-tools/tests/xgettext-its-1
Executable file
@ -0,0 +1,132 @@
|
||||
#!/bin/sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
|
||||
|
||||
# Test of ITS support.
|
||||
|
||||
: ${XGETTEXT=xgettext}
|
||||
: ${GETTEXTDATADIR=.}
|
||||
|
||||
export GETTEXTDATADIR
|
||||
|
||||
cat <<\EOF > empty.xml
|
||||
<?xml version="1.0"?>
|
||||
<empty></empty>
|
||||
EOF
|
||||
|
||||
${XGETTEXT} --its -o empty.pot empty.xml 2>empty.err || { cat empty.err; exit 1; }
|
||||
|
||||
test -d its || mkdir its
|
||||
test -d its/locators || mkdir its/locators
|
||||
test -d its/rules || mkdir its/rules
|
||||
|
||||
cat <<\EOF > its/locators/empty-1.loc
|
||||
<?xml version="1.0"?>
|
||||
<locatingRules/>
|
||||
EOF
|
||||
|
||||
${XGETTEXT} --its -o empty.pot empty.xml 2>empty.err || { cat empty.err; exit 1; }
|
||||
|
||||
cat <<\EOF > its/locators/empty-2.loc
|
||||
<?xml version="1.0"?>
|
||||
<locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0">
|
||||
<documentElement prefix="" localName="empty" uri="empty.its"/>
|
||||
</locatingRules>
|
||||
EOF
|
||||
|
||||
${XGETTEXT} --its -o empty.pot empty.xml 2>empty.err || { cat empty.err; exit 1; }
|
||||
|
||||
cat <<\EOF > its/rules/empty.its
|
||||
<?xml version="1.0"?>
|
||||
<its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0">
|
||||
</its:rules>
|
||||
EOF
|
||||
|
||||
${XGETTEXT} --its -o empty.pot empty.xml 2>empty.err || { cat empty.err; exit 1; }
|
||||
|
||||
cat <<\EOF > its/locators/messages.loc
|
||||
<?xml version="1.0"?>
|
||||
<locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0">
|
||||
<documentElement prefix="" localName="messages" uri="messages.its"/>
|
||||
</locatingRules>
|
||||
EOF
|
||||
|
||||
cat <<\EOF > its/rules/messages.its
|
||||
<?xml version="1.0"?>
|
||||
<its:rules xmlns:its="http://www.w3.org/2005/11/its"
|
||||
xmlns:msg="http://www.gnu.org/s/gettext/ns/messages/1.0"
|
||||
version="1.0">
|
||||
<its:translateRule selector="//msg:message/@comment" translate="yes"/>
|
||||
<its:translateRule selector="//msg:note" translate="no"/>
|
||||
<its:locNoteRule selector="//msg:message/*" locNoteType="alert" locNotePointer="../msg:note"/>
|
||||
<its:withinTextRule selector="//msg:span" withinText="yes"/>
|
||||
<its:preserveSpaceRule selector="//msg:code" space="preserve"/>
|
||||
</its:rules>
|
||||
EOF
|
||||
|
||||
cat <<\EOF >messages.xml
|
||||
<messages xmlns="http://www.gnu.org/s/gettext/ns/messages/1.0">
|
||||
<message>
|
||||
<p>This is a test message</p>
|
||||
</message>
|
||||
<message>
|
||||
<p>This is a test message, with an <span>element</span> in a text</p>
|
||||
</message>
|
||||
<message>
|
||||
<p>This is a test message, with an code in a text<code>
|
||||
$ echo foo >> /dev/null
|
||||
</code>
|
||||
</p>
|
||||
</message>
|
||||
<message comment="This is a comment">
|
||||
<p>This is a test message, with an attribute</p>
|
||||
</message>
|
||||
<message>
|
||||
<note>
|
||||
This is a localization note
|
||||
</note>
|
||||
<p>This is a test message, with a localization note</p>
|
||||
</message>
|
||||
</messages>
|
||||
EOF
|
||||
|
||||
cat <<\EOF >messages.ok
|
||||
#. (itstool) path: message/p
|
||||
#: messages.xml:3
|
||||
msgid "This is a test message"
|
||||
msgstr ""
|
||||
|
||||
#. (itstool) path: message/p
|
||||
#: messages.xml:6
|
||||
msgid "This is a test message, with an <span>element</span> in a text"
|
||||
msgstr ""
|
||||
|
||||
#. (itstool) path: p/code
|
||||
#: messages.xml:9
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\n"
|
||||
"$ echo foo >> /dev/null\n"
|
||||
msgstr ""
|
||||
|
||||
#. (itstool) path: messages/message@comment
|
||||
#: messages.xml:14
|
||||
msgid "This is a comment"
|
||||
msgstr ""
|
||||
|
||||
#. (itstool) path: message/p
|
||||
#: messages.xml:15
|
||||
msgid "This is a test message, with an attribute"
|
||||
msgstr ""
|
||||
|
||||
#. This is a localization note
|
||||
#. (itstool) path: message/p
|
||||
#: messages.xml:21
|
||||
msgid "This is a test message, with a localization note"
|
||||
msgstr ""
|
||||
EOF
|
||||
|
||||
${XGETTEXT} --its --omit-header -o messages.pot messages.xml 2>messages.err || { cat messages.err; exit 1; }
|
||||
|
||||
: ${DIFF=diff}
|
||||
${DIFF} messages.ok messages.pot
|
||||
result=$?
|
||||
Loading…
x
Reference in New Issue
Block a user