1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
# Test of JavaScript support: tagged template literals.
cat <<\EOF > xg-js-13.js
var s0 = _`A template literal without substitutions`;
var s1 = _ `A template literal with
embedded
newlines`);
var s2 = _ /* XYZZY */ `A template literal with ${n} substitutions`;
var s3 = _`A template literal with several substitutions: ${a} and ${b} and ${c} and so on`;
var s4 = `/${looks_like_regex}`;
var s5 = _('not part of a regex');
var s6 = _`that's a valid string. ` + _('This too');
var s7 = _ tag`A template literal with two tags`;
var s8 = _`a${_`b${_`c`+d}`}e`;
var s9 = _("a normal string");
var s10 = _`abc${foo({},_('should be extracted'))}xyz`;
var f1 = function () {
return _("first normal string") + _`${foo}` + _("second normal string");
};
var s11 = _("another normal string");
var s12 = { property: _`A template literal with ${n} substitution` };
var s13 = _("yet another normal string");
// Mixing JSX with template literals.
var s14 = 0;
var s15 = (
<div>
_("Expected translation string #10");
{_`pre11${ _("Expected translation string #11") }post11`}
_("Expected translation string #12");
</div>
);
var s16 = _("Expected translation string #13");
var s17 = <div className={_`pre14${ _("Expected translation string #14") }post14`} /> ;
var s18 = _("Expected translation string #15");
var s19 = { a: 1, b: <div className={_`pre16${ _("Expected translation string #16") }post16`} /> };
var s20 = _("Expected translation string #17");
var s21 = _`begin${ <div> _("Expected translation string #18") </div> }end`;
var s22 = _("Expected translation string #19");
EOF
: ${XGETTEXT=xgettext}
${XGETTEXT} --add-comments --no-location --tag=_:javascript-gnome-format \
-o xg-js-13.tmp xg-js-13.js 2>xg-js-13.err
test $? = 0 || { cat xg-js-13.err; Exit 1; }
func_filter_POT_Creation_Date xg-js-13.tmp xg-js-13.pot
cat <<\EOF > xg-js-13.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "A template literal without substitutions"
msgstr ""
msgid ""
"A template literal with\n"
"embedded\n"
"newlines"
msgstr ""
#. XYZZY
msgid "A template literal with {0} substitutions"
msgstr ""
msgid ""
"A template literal with several substitutions: {0} and {1} and {2} and so on"
msgstr ""
msgid "not part of a regex"
msgstr ""
msgid "that's a valid string. "
msgstr ""
msgid "This too"
msgstr ""
msgid "c"
msgstr ""
msgid "b{0}"
msgstr ""
msgid "a{0}e"
msgstr ""
msgid "a normal string"
msgstr ""
msgid "should be extracted"
msgstr ""
msgid "abc{0}xyz"
msgstr ""
msgid "first normal string"
msgstr ""
msgid "{0}"
msgstr ""
msgid "second normal string"
msgstr ""
msgid "another normal string"
msgstr ""
msgid "A template literal with {0} substitution"
msgstr ""
msgid "yet another normal string"
msgstr ""
msgid "Expected translation string #10"
msgstr ""
msgid "Expected translation string #11"
msgstr ""
msgid "pre11{0}post11"
msgstr ""
msgid "Expected translation string #12"
msgstr ""
msgid "Expected translation string #13"
msgstr ""
msgid "Expected translation string #14"
msgstr ""
msgid "pre14{0}post14"
msgstr ""
msgid "Expected translation string #15"
msgstr ""
msgid "Expected translation string #16"
msgstr ""
msgid "pre16{0}post16"
msgstr ""
msgid "Expected translation string #17"
msgstr ""
msgid "Expected translation string #18"
msgstr ""
msgid "begin{0}end"
msgstr ""
msgid "Expected translation string #19"
msgstr ""
EOF
: ${DIFF=diff}
${DIFF} xg-js-13.ok xg-js-13.pot
result=$?
exit $result
|