• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test of JavaScript template literal support.
5
6cat <<\EOF > xg-js-7.js
7var s0 = _(`A template literal without substitutions`);
8var s1 = _(`A template literal with
9embedded
10newlines`);
11var s2 = _(`A template literal with ${n} substitutions`);
12var s3 = _(`A template literal with several substitutions: ${a} and ${b} and ${c} and so on`);
13var s4 = `/${looks_like_regex}`;
14var s5 = _('not part of a regex');
15var s6 = `that's a valid string. ` + _('This too');
16var s7 = _(tag`A template literal with a tag`);
17var s8 = `a${`b${`c`+d}`}e`;
18var s9 = _("a normal string");
19var s10 = `abc${foo({},_('should be extracted'))}xyz`;
20var f1 = function () {
21  return _("first normal string") + `${foo}` + _("second normal string");
22};
23var s11 = _("another normal string");
24var s12 = { property: `A template literal with ${n} substitution` };
25var s13 = _("yet another normal string");
26
27EOF
28
29: ${XGETTEXT=xgettext}
30${XGETTEXT} --add-comments --no-location -o xg-js-7.tmp xg-js-7.js 2>xg-js-7.err
31test $? = 0 || { cat xg-js-7.err; Exit 1; }
32func_filter_POT_Creation_Date xg-js-7.tmp xg-js-7.pot
33
34cat <<\EOF > xg-js-7.ok
35# SOME DESCRIPTIVE TITLE.
36# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
37# This file is distributed under the same license as the PACKAGE package.
38# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
39#
40#, fuzzy
41msgid ""
42msgstr ""
43"Project-Id-Version: PACKAGE VERSION\n"
44"Report-Msgid-Bugs-To: \n"
45"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
46"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
47"Language-Team: LANGUAGE <LL@li.org>\n"
48"Language: \n"
49"MIME-Version: 1.0\n"
50"Content-Type: text/plain; charset=CHARSET\n"
51"Content-Transfer-Encoding: 8bit\n"
52
53msgid "A template literal without substitutions"
54msgstr ""
55
56msgid ""
57"A template literal with\n"
58"embedded\n"
59"newlines"
60msgstr ""
61
62msgid "not part of a regex"
63msgstr ""
64
65msgid "This too"
66msgstr ""
67
68msgid "a normal string"
69msgstr ""
70
71msgid "should be extracted"
72msgstr ""
73
74msgid "first normal string"
75msgstr ""
76
77msgid "second normal string"
78msgstr ""
79
80msgid "another normal string"
81msgstr ""
82
83msgid "yet another normal string"
84msgstr ""
85EOF
86
87: ${DIFF=diff}
88${DIFF} xg-js-7.ok xg-js-7.pot
89result=$?
90
91exit $result
92