#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test of JavaScript support: string concatenation.
-# Playing with concatenation of string literals within the gettext arguments.
+# Test of JavaScript support: string concatenation,
+# strings with embedded expressions.
cat <<\EOF > xg-js-3.js
// The usual way to concatenate strings is the plus '+' sign
_("This" + " whole " // c
+ "string" + // d
' should' + " be " + 'extracted');
+// Strings with embedded expressions, a.k.a. template literals.
+var t = "";
+var e1 = _(`embedded_1_${foo}_bar`);
+var e2 = _(`embedded_2_${_("embedded_2_sub1")}_bar_${_('embedded_2_sub2')}_baz`);
+var e3 = _(`embedded_3`);
EOF
: ${XGETTEXT=xgettext}
#. b
msgid "This whole string should be extracted"
msgstr ""
+
+msgid "embedded_2_sub1"
+msgstr ""
+
+msgid "embedded_2_sub2"
+msgstr ""
+
+msgid "embedded_3"
+msgstr ""
EOF
: ${DIFF=diff}
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test of Python support: escape sequences, string concatenation.
+# Test of Python support: escape sequences, string concatenation,
+# strings with embedded expressions.
cat <<\EOF > xg-py-1.py
# interpret_ansic = true, interpret_unicode = false, f_string = false
# string concatenation
_("abc" "def" + "ghi"
"jkl" + mno)
+
+# strings with embedded expressions
+_(f"embedded_1_{foo}_bar");
+_(f"embedded_2_{_('embedded_2_sub1')}_bar_{_('embedded_2_sub2')}_baz");
+_(f"embedded_3");
EOF
: ${XGETTEXT=xgettext}
#. string concatenation
msgid "abcdefghijkl"
msgstr ""
+
+msgid "embedded_2_sub1"
+msgstr ""
+
+msgid "embedded_2_sub2"
+msgstr ""
+
+msgid "embedded_3"
+msgstr ""
EOF
: ${DIFF=diff}
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test Ruby support: --add-comments option, string concatenation.
+# Test Ruby support: --add-comments option, string concatenation,
+# strings with embedded expressions.
(rxgettext --version) >/dev/null 2>/dev/null \
|| { echo "Skipping test: rxgettext not found"; Exit 77; }
_( "hello " + # d
"world" # e
);
+# Strings with embedded expressions, a.k.a. interpolated strings.
+t = "";
+_("embedded_1_#{foo}_bar");
+_("embedded_2_#{_("embedded_2_sub1")}_bar_#{_("embedded_2_sub2")}_baz");
+_("embedded_3");
EOF
: ${XGETTEXT=xgettext}
#. c
msgid "hello world"
msgstr ""
+
+msgid "embedded_2_sub1"
+msgstr ""
+
+msgid "embedded_2_sub2"
+msgstr ""
+
+msgid "embedded_3"
+msgstr ""
EOF
: ${DIFF=diff}
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test of Shell support: escape sequences, string concatenation.
+# Test of Shell support: escape sequences, string concatenation,
+# strings with embedded expressions.
cat <<\EOF > xg-sh-1.sh
# Test escape sequences expansion.
gettext concat_7_'part2'
gettext concat_8_ part2
gettext "concat_9_"'part2'"part3"
+
+# Test strings with embedded expressions.
+
+gettext "embedded_1_${foo}_bar"
+gettext "embedded_2_${foo-`gettext embedded_2_sub1`}_bar_${foo-`gettext embedded_2_sub2`}_baz"
+gettext "embedded_3_${foo:-`gettext embedded_3_sub1`}_bar_${foo:-`gettext embedded_3_sub2`}_baz"
+gettext "embedded_4"
EOF
: ${XGETTEXT=xgettext}
msgid "concat_9_part2part3"
msgstr ""
+
+msgid "embedded_2_sub1"
+msgstr ""
+
+msgid "embedded_2_sub2"
+msgstr ""
+
+msgid "embedded_3_sub1"
+msgstr ""
+
+msgid "embedded_3_sub2"
+msgstr ""
+
+msgid "embedded_4"
+msgstr ""
EOF
: ${DIFF=diff}
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test Tcl support: --add-comments option.
+# Test Tcl support: --add-comments option, strings with embedded expressions.
cat <<\EOF > xg-t-2.tcl
# This comment will not be extracted.
# TRANSLATORS:
# Nickname of the Beatles
puts [_ "The Fabulous Four"]
+# Strings with embedded expressions, a.k.a. variable substitution.
+puts [_ "embedded_1_$foo_bar"]
+puts [_ "embedded_2_$myArray([$myFunction [_ "embedded_2_sub1"]])_bar_$myArray($myIndices([$myFunction [_ "embedded_2_sub2"]]))_baz"];
+puts [_ "embedded_3"]
EOF
: ${XGETTEXT=xgettext}
#. Nickname of the Beatles
msgid "The Fabulous Four"
msgstr ""
+
+msgid "embedded_2_sub1"
+msgstr ""
+
+msgid "embedded_2_sub2"
+msgstr ""
+
+msgid "embedded_3"
+msgstr ""
EOF
: ${DIFF=diff}