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