Imported Upstream version 0.18.3.2
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-javascript-1
1 #!/bin/sh
2
3 # Test of JavaScript support.
4
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
7
8 tmpfiles="$tmpfiles xg-js-1.js"
9 cat <<\EOF > xg-js-1.js
10 var s1 = "Simple string, no gettext needed",
11     s2 = _("Extract this first string");
12 function foo(a) {
13     var s3 = "Prefix _(" + _("Extract this second string") + ") Postfix";
14 }
15 if (document.getElementsById("foo")[0].innerHTML == _("Extract this thirth string")) {
16     /* _("This is a comment and must not be extracted!") */
17 }
18 EOF
19
20 tmpfiles="$tmpfiles xg-js-1.err xg-js-1.tmp xg-js-1.pot"
21 : ${XGETTEXT=xgettext}
22 ${XGETTEXT} --add-comments --no-location -o xg-js-1.tmp xg-js-1.js 2>xg-js-1.err
23 test $? = 0 || { cat xg-js-1.err; rm -fr $tmpfiles; exit 1; }
24 # Don't simplify this to "grep ... < xg-js-1.tmp", otherwise OpenBSD 4.0 grep
25 # only outputs "Binary file (standard input) matches".
26 cat xg-js-1.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-js-1.pot
27
28 tmpfiles="$tmpfiles xg-js-1.ok"
29 cat <<\EOF > xg-js-1.ok
30 # SOME DESCRIPTIVE TITLE.
31 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
32 # This file is distributed under the same license as the PACKAGE package.
33 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
34 #
35 #, fuzzy
36 msgid ""
37 msgstr ""
38 "Project-Id-Version: PACKAGE VERSION\n"
39 "Report-Msgid-Bugs-To: \n"
40 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
41 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
42 "Language-Team: LANGUAGE <LL@li.org>\n"
43 "Language: \n"
44 "MIME-Version: 1.0\n"
45 "Content-Type: text/plain; charset=CHARSET\n"
46 "Content-Transfer-Encoding: 8bit\n"
47
48 msgid "Extract this first string"
49 msgstr ""
50
51 msgid "Extract this second string"
52 msgstr ""
53
54 msgid "Extract this thirth string"
55 msgstr ""
56 EOF
57
58 : ${DIFF=diff}
59 ${DIFF} xg-js-1.ok xg-js-1.pot
60 result=$?
61
62 rm -fr $tmpfiles
63
64 exit $result