* gettext-tools/tests/xgettext-sh-1: Add string concatenation tests.
* gettext-tools/tests/xgettext-lua-1: Add a string concatenation test.
* gettext-tools/tests/xgettext-vala-1: Likewise.
* gettext-tools/tests/xgettext-javascript-3: Enhance the string concatenation
test.
* gettext-tools/tests/xgettext-csharp-5: Update comment.
* gettext-tools/tests/xgettext-csharp-6: Likewise.
* gettext-tools/tests/xgettext-java-5: Likewise.
* gettext-tools/tests/xgettext-java-6: Likewise.
* gettext-tools/tests/xgettext-lua-2: Likewise.
* gettext-tools/tests/xgettext-perl-7: Likewise.
* gettext-tools/tests/xgettext-php-3: Likewise.
* gettext-tools/tests/xgettext-python-1: Likewise.
* gettext-tools/tests/xgettext-python-2: Likewise.
* gettext-tools/tests/xgettext-python-4: Likewise.
* gettext-tools/tests/xgettext-ruby-1: Likewise.
* gettext-tools/tests/xgettext-sh-5: Likewise.
* gettext-tools/tests/xgettext-ruby-2: New file, based on
gettext-tools/tests/xgettext-csharp-6.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
xgettext-python-7 xgettext-python-8 \
xgettext-python-stackovfl-1 xgettext-python-stackovfl-2 \
xgettext-python-stackovfl-3 xgettext-python-stackovfl-4 \
- xgettext-ruby-1 \
+ xgettext-ruby-1 xgettext-ruby-2 \
xgettext-scheme-1 xgettext-scheme-2 xgettext-scheme-3 \
xgettext-scheme-4 xgettext-scheme-5 xgettext-scheme-6 \
xgettext-scheme-7 xgettext-scheme-8 \
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test C# support: --add-comments option.
+# Test C# support: --add-comments option, string concatenation.
cat <<\EOF > xg-cs-5.cs
// This comment will not be extracted.
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test C# support: --add-comments option.
+# Test C# support: --add-comments option, string concatenation.
cat <<\EOF > xg-cs-6.cs
/* a */
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test Java support: --add-comments option.
+# Test Java support: --add-comments option, string concatenation.
cat <<\EOF > xg-j-5.java
// This comment will not be extracted.
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test Java support: --add-comments option.
+# Test Java support: --add-comments option, string concatenation.
cat <<\EOF > xg-j-6.java
/* a */
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test of JavaScript support.
-# Playing with concatenation of string literals within the gettext function
+# Test of JavaScript support: string concatenation.
+# Playing with concatenation of string literals within the gettext arguments.
cat <<\EOF > xg-js-3.js
// The usual way to concatenate strings is the plus '+' sign
+var s0;
var s1 = _("Concatenation #1 " + "- String part added");
var s2 = _('Concatenation #2 ' + '- String part added');
-var s3 = _("This" + " whole "
- + "string" +
+// a
+var s3 = // b
+ _("This" + " whole " // c
+ + "string" + // d
' should' + " be " + 'extracted');
EOF
: ${XGETTEXT=xgettext}
-${XGETTEXT} --add-comments=TRANSLATORS: --no-location -o xg-js-3.tmp xg-js-3.js 2>xg-js-3.err
+${XGETTEXT} --add-comments --no-location -o xg-js-3.tmp xg-js-3.js 2>xg-js-3.err
test $? = 0 || { cat xg-js-3.err; Exit 1; }
func_filter_POT_Creation_Date xg-js-3.tmp xg-js-3.pot
msgid "Concatenation #2 - String part added"
msgstr ""
+#. a
+#. b
msgid "This whole string should be extracted"
msgstr ""
EOF
print(_("\097"))
print(_("\x3F\z
\x2a"))
+-- String concatenation in regular contexts.
print(_("abc" .. "def"))
+-- String concatenation *not* happening when the parentheses are omitted.
+print(_"hello" " world")
+
print(speed / 1000 .. 'Mbps')
EOF
msgid "abcdef"
msgstr ""
+
+msgid "hello"
+msgstr ""
EOF
: ${DIFF=diff}
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test Lua comment syntax
+# Test Lua support: comment syntax, string concatenation
cat <<\EOF > xg-lu-2.lua
-- This comment won't be extracted.
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test Perl support: --add-comments option.
+# Test Perl support: --add-comments option, string concatenation.
cat <<\EOF > xg-pl-7.pl
# a
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test PHP support: --add-comments option.
+# Test PHP support: --add-comments option, string concatenation.
cat <<\EOF > xg-ph-3.php
<?
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test of Python support.
+# Test of Python support: escape sequences, string concatenation.
cat <<\EOF > xg-py-1.py
# interpret_ansic = true, interpret_unicode = false, f_string = false
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test Python support: --add-comments option.
+# Test Python support: --add-comments option, string concatenation.
cat <<\EOF > xg-py-2.py
# This comment will not be extracted.
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test Python support: --add-comments option.
+# Test Python support: --add-comments option, string concatenation.
cat <<\EOF > xg-py-4.py
# a
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test of Ruby support.
+# Test of Ruby support: --add-comments option.
(rxgettext --version) >/dev/null 2>/dev/null \
|| { echo "Skipping test: rxgettext not found"; Exit 77; }
--- /dev/null
+#!/bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test Ruby support: --add-comments option, string concatenation.
+
+cat <<\EOF > xg-ru-2.rb
+# a
+s = # b
+# c
+_( "hello " + # d
+ "world" # e
+ );
+EOF
+
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --add-comments --omit-header --no-location --keyword=_ \
+ -d xg-ru-2.tmp xg-ru-2.rb || Exit 1
+LC_ALL=C tr -d '\r' < xg-ru-2.tmp.po > xg-ru-2.po || Exit 1
+
+cat <<\EOF > xg-ru-2.ok
+#. a
+#. b
+#. c
+msgid "hello world"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-ru-2.ok xg-ru-2.po
+result=$?
+
+exit $result
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test of Shell support.
+# Test of Shell support: escape sequences, string concatenation.
cat <<\EOF > xg-sh-1.sh
# Test escape sequences expansion.
echo "`echo "\`ngettext 'depth_2_11_squote_6_semi \\\\\\;'\`"`"
echo "`echo "\`ngettext 'depth_2_11_squote_7_semi \\\\\\\;'\`"`"
echo "`echo "\`ngettext 'depth_2_11_squote_8_semi \\\\\\\\;'\`"`"
+
+# Test string concatenation.
+
+gettext "concat_0_""part2"
+gettext "concat_1_"'part2'
+gettext "concat_2_"part2
+gettext 'concat_3_'"part2"
+gettext 'concat_4_''part2'
+gettext 'concat_5_'part2
+gettext concat_6_"part2"
+gettext concat_7_'part2'
+gettext concat_8_ part2
+gettext "concat_9_"'part2'"part3"
EOF
: ${XGETTEXT=xgettext}
msgid "depth_2_11_squote_8_semi \\\\;"
msgstr ""
+
+msgid "concat_0_part2"
+msgstr ""
+
+msgid "concat_1_part2"
+msgstr ""
+
+msgid "concat_2_part2"
+msgstr ""
+
+msgid "concat_3_part2"
+msgstr ""
+
+msgid "concat_4_part2"
+msgstr ""
+
+msgid "concat_5_part2"
+msgstr ""
+
+msgid "concat_6_part2"
+msgstr ""
+
+msgid "concat_7_part2"
+msgstr ""
+
+msgid "concat_8_"
+msgstr ""
+
+msgid "concat_9_part2part3"
+msgstr ""
EOF
: ${DIFF=diff}
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
-# Test of Shell support: bash $(...) syntax.
+# Test of Shell support: POSIX $(...) syntax.
cat <<\EOF > xg-sh-5.sh
echo $(gettext 'Simple string')
multiline C style comment */
var s7 = _("Extract this //sixth string");
- var s8 = _(@"This is a template string, which cannot be extracted!");
+ // a
+ var s8 = /* b */
+ _("This" + " whole " // c
+ + "string" + // d
+ """ should""" + " be " + """extracted""");
+
+ var s9 = _(@"This is a template string, which cannot be extracted!");
/* /= shouldn't start a regex literal */
var i5 = 1000;
#. multiline C style comment
msgid "Extract this //sixth string"
msgstr ""
+
+#. a
+#. b
+msgid "This whole string should be extracted"
+msgstr ""
EOF
: ${DIFF=diff}
#. multiline C style comment
msgid "Extract this //sixth string"
msgstr ""
+
+#. a
+#. b
+msgid "This whole string should be extracted"
+msgstr ""
EOF
${DIFF} xg-vala-1.all.ok xg-vala-1.pot