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