]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
javascript: fix translator comment extraction in C++-style comments
authorDaiki Ueno <ueno@gnu.org>
Thu, 14 Nov 2013 07:10:03 +0000 (16:10 +0900)
committerDaiki Ueno <ueno@gnu.org>
Thu, 14 Nov 2013 07:10:03 +0000 (16:10 +0900)
* src/x-javascript.c (phase3_getc): Make sure to call comment_line_end
after parsing C++ style comment line.
Reported by Illimar Tambek at: <http://savannah.gnu.org/bugs/?40572>.

* tests/xgettext-javascript-1: Add a test to extract translator comments
from C++ style comment lines; only extract comments with
TRANSLATORS: tag.
* tests/xgettext-javascript-3: Only extract comments with TRANSLATORS:
tag.

gettext-tools/src/ChangeLog
gettext-tools/src/x-javascript.c
gettext-tools/tests/xgettext-javascript-1
gettext-tools/tests/xgettext-javascript-3

index c15fd7dfad836e53680692a23e5967987eafda32..97c3c1f3216d0131a68730753ede0332066d6b10 100644 (file)
@@ -1,3 +1,9 @@
+2013-11-14  Daiki Ueno  <ueno@gnu.org>
+
+       * x-javascript.c (phase3_getc): Make sure to call comment_line_end
+       after parsing C++ style comment line.
+       Reported by Illimar Tambek at: <http://savannah.gnu.org/bugs/?40572>.
+
 2013-11-14  Daiki Ueno  <ueno@gnu.org>
 
        * x-javascript.c (comment_line_end): Add missing chars_to_remove
index 9d166714fb8c42cb7345cc0f0cc70b623aef1cac..c1503cef5bbfedd97b3110c6738c5053a9ea866e 100644 (file)
@@ -619,7 +619,10 @@ phase3_getc ()
                 {
                   c = phase2_getc ();
                   if (c == UEOF || c == '\n')
-                    break;
+                    {
+                      comment_line_end (0);
+                      break;
+                    }
                   /* We skip all leading white space, but not EOLs.  */
                   if (!(comment_at_start () && (c == ' ' || c == '\t')))
                     comment_add (c);
index 2f8115f92a42257d310d283f138938c3c1f64caa..83d8412657160147dfc1fa76b3286b822406194a 100755 (executable)
@@ -18,11 +18,13 @@ if (document.getElementsById("foo")[0].innerHTML == _("Extract this third string
 }
 /* TRANSLATORS: This is a translator comment.  */
 gettext('Extract this fourth string');
+// TRANSLATORS: This is another translator comment.
+gettext('Extract this fifth string');
 EOF
 
 tmpfiles="$tmpfiles xg-js-1.err xg-js-1.tmp xg-js-1.pot"
 : ${XGETTEXT=xgettext}
-${XGETTEXT} --add-comments --no-location -o xg-js-1.tmp xg-js-1.js 2>xg-js-1.err
+${XGETTEXT} --add-comments=TRANSLATORS: --no-location -o xg-js-1.tmp xg-js-1.js 2>xg-js-1.err
 test $? = 0 || { cat xg-js-1.err; rm -fr $tmpfiles; exit 1; }
 # Don't simplify this to "grep ... < xg-js-1.tmp", otherwise OpenBSD 4.0 grep
 # only outputs "Binary file (standard input) matches".
@@ -60,6 +62,10 @@ msgstr ""
 #. TRANSLATORS: This is a translator comment.
 msgid "Extract this fourth string"
 msgstr ""
+
+#. TRANSLATORS: This is another translator comment.
+msgid "Extract this fifth string"
+msgstr ""
 EOF
 
 : ${DIFF=diff}
index c7dd9565c518850b57d19479fe3441604748abd4..95ced524f045bfe982b0bfb8e8c9846a9c1fab47 100755 (executable)
@@ -19,7 +19,7 @@ EOF
 
 tmpfiles="$tmpfiles xg-js-3.err xg-js-3.tmp xg-js-3.pot"
 : ${XGETTEXT=xgettext}
-${XGETTEXT} --add-comments --no-location -o xg-js-3.tmp xg-js-3.js 2>xg-js-3.err
+${XGETTEXT} --add-comments=TRANSLATORS: --no-location -o xg-js-3.tmp xg-js-3.js 2>xg-js-3.err
 test $? = 0 || { cat xg-js-3.err; rm -fr $tmpfiles; exit 1; }
 # Don't simplify this to "grep ... < xg-js-3.tmp", otherwise OpenBSD 4.0 grep
 # only outputs "Binary file (standard input) matches".