Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-javascript-6
1 #!/bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test of JavaScript E4X support.
5
6 cat <<\EOF > xg-js-6.js
7 var x1 = <x1></x1>;
8 var s1 = _("Expected translation string #1");
9 var s2 = "foo";
10 var x2 = <{s2}>foo {s2} bar</{s2}>;
11 var x3 = <x3 a1="/"><x4>{_("Expected translation string #2")}</x4></x3>;
12 var x4 = <x5 a2='/'><x{_("Expected translation string #3")}>
13 </x{_("Expected translation string #3")}></x5>;
14 var x4 = <![CDATA[
15   _("Unexpected translation string #1")
16 ]]>;
17 var x5 = <!-- - _("Unexpected translation string #2") - -->;
18 var s6 = _("Expected translation string #4");
19 var x6 = <? _("Unexpected translation string #3") ?>;
20 var x7 = <!--- this is a comment --> <foo>
21 var s7 = "<{x6}>_("Unexpected translation string #4")</{x6}>" +
22          "<!-- _("Unexpected translation string #5") --!>" +
23          _("Expected translation string #5");
24 var s8 = _("<x7>Expected translation string #6</x7>");
25 var x8 = <x8><x9>{_("<x8>{Expected translation string #7}</x8>")}</x9></x8>
26 var x9 = <x10 attr='{_("Unexpected translation string #6")}'><x11>data</x11></x10>;
27 var s9 = _("Expected translation string #8");
28 </foo>;
29 EOF
30
31 : ${XGETTEXT=xgettext}
32 ${XGETTEXT} --add-comments --no-location -o xg-js-6.tmp xg-js-6.js 2>xg-js-6.err
33 test $? = 0 || { cat xg-js-6.err; exit 1; }
34 # Don't simplify this to "grep ... < xg-js-6.tmp", otherwise OpenBSD 4.0 grep
35 # only outputs "Binary file (standard input) matches".
36 cat xg-js-6.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-js-6.pot
37
38 cat <<\EOF > xg-js-6.ok
39 # SOME DESCRIPTIVE TITLE.
40 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
41 # This file is distributed under the same license as the PACKAGE package.
42 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
43 #
44 #, fuzzy
45 msgid ""
46 msgstr ""
47 "Project-Id-Version: PACKAGE VERSION\n"
48 "Report-Msgid-Bugs-To: \n"
49 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
50 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
51 "Language-Team: LANGUAGE <LL@li.org>\n"
52 "Language: \n"
53 "MIME-Version: 1.0\n"
54 "Content-Type: text/plain; charset=CHARSET\n"
55 "Content-Transfer-Encoding: 8bit\n"
56
57 msgid "Expected translation string #1"
58 msgstr ""
59
60 msgid "Expected translation string #2"
61 msgstr ""
62
63 msgid "Expected translation string #3"
64 msgstr ""
65
66 msgid "Expected translation string #4"
67 msgstr ""
68
69 msgid "Expected translation string #5"
70 msgstr ""
71
72 msgid "<x7>Expected translation string #6</x7>"
73 msgstr ""
74
75 msgid "<x8>{Expected translation string #7}</x8>"
76 msgstr ""
77
78 msgid "Expected translation string #8"
79 msgstr ""
80 EOF
81
82 : ${DIFF=diff}
83 ${DIFF} xg-js-6.ok xg-js-6.pot
84 result=$?
85
86 exit $result