From: Daiki Ueno Date: Thu, 14 Nov 2013 02:12:52 +0000 (+0900) Subject: javascript: fix translator comment extraction in C-style comments X-Git-Tag: v0.19~160 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64427a17b7d50d509d54f60aa159c7107bd0e5c6;p=thirdparty%2Fgettext.git javascript: fix translator comment extraction in C-style comments * src/x-javascript.c (comment_line_end): Add missing chars_to_remove argument; all callers changed. Reported by Illimar Tambek at: . * tests/xgettext-javascript-1: Add a test to extract translator comments. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index a7f54226f..c15fd7dfa 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,9 @@ +2013-11-14 Daiki Ueno + + * x-javascript.c (comment_line_end): Add missing chars_to_remove + argument; all callers changed. + Reported by Illimar Tambek at: . + 2013-11-11 Daiki Ueno * x-c.c (phase5_get): Fix misuse of a logical operator. diff --git a/gettext-tools/src/x-javascript.c b/gettext-tools/src/x-javascript.c index 565d84ff0..9d166714f 100644 --- a/gettext-tools/src/x-javascript.c +++ b/gettext-tools/src/x-javascript.c @@ -545,10 +545,10 @@ comment_add (int c) } static inline const char * -comment_line_end () +comment_line_end (size_t chars_to_remove) { char *buffer = unicode_string_buffer_result (&comment_buffer); - size_t buflen = strlen (buffer); + size_t buflen = strlen (buffer) - chars_to_remove; while (buflen >= 1 && (buffer[buflen - 1] == ' ' || buffer[buflen - 1] == '\t')) diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index f9cb507eb..33efe8da7 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,7 @@ +2013-11-14 Daiki Ueno + + * xgettext-javascript-1: Add a test to extract translator comments. + 2013-08-30 Daiki Ueno * Makefile.am (gettextpo_1_prg_CPPFLAGS): Don't add 'gnulib-lib' diff --git a/gettext-tools/tests/xgettext-javascript-1 b/gettext-tools/tests/xgettext-javascript-1 index 57a832df7..2f8115f92 100755 --- a/gettext-tools/tests/xgettext-javascript-1 +++ b/gettext-tools/tests/xgettext-javascript-1 @@ -13,9 +13,11 @@ var s1 = "Simple string, no gettext needed", function foo(a) { var s3 = "Prefix _(" + _("Extract this second string") + ") Postfix"; } -if (document.getElementsById("foo")[0].innerHTML == _("Extract this thirth string")) { +if (document.getElementsById("foo")[0].innerHTML == _("Extract this third string")) { /* _("This is a comment and must not be extracted!") */ } +/* TRANSLATORS: This is a translator comment. */ +gettext('Extract this fourth string'); EOF tmpfiles="$tmpfiles xg-js-1.err xg-js-1.tmp xg-js-1.pot" @@ -52,7 +54,11 @@ msgstr "" msgid "Extract this second string" msgstr "" -msgid "Extract this thirth string" +msgid "Extract this third string" +msgstr "" + +#. TRANSLATORS: This is a translator comment. +msgid "Extract this fourth string" msgstr "" EOF