bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gettext] [PATCH] Extraction bug from .ui file of GTK+


From: Daiki Ueno
Subject: Re: [bug-gettext] [PATCH] Extraction bug from .ui file of GTK+
Date: Mon, 12 Aug 2013 12:52:38 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Daiki Ueno <address@hidden> writes:

> Instead, remember_a_message should handle multiline extracted_comment
> properly, as po_message_set_extracted_comment does:

I've pushed this as attached, so it can be included in 0.18.3.1.

>From 4069d98879838c0c8a766f9d04f0a5d0c2811a07 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <address@hidden>
Date: Mon, 12 Aug 2013 12:12:12 +0200
Subject: [PATCH] glade: handle multi-line extracted comments

---
 gettext-tools/src/ChangeLog          |  7 +++++++
 gettext-tools/src/xgettext.c         | 24 +++++++++++++++++++++++-
 gettext-tools/tests/ChangeLog        |  4 ++++
 gettext-tools/tests/xgettext-glade-7 | 24 ++++++++++++++++--------
 4 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 38dc376..5389874 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,10 @@
+2013-08-12  Daiki Ueno  <address@hidden>
+
+       * xgettext.c (remember_a_message): Handle multi-line extracted
+       comments.
+       Reported by Gabor Kelemen in
+       <http://lists.gnu.org/archive/html/bug-gettext/2013-08/msg00026.html>.
+
 2013-08-09  Daiki Ueno  <address@hidden>
 
        * x-gsettings.c (extract_gsettings): Add guard when expat is not
diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c
index c6b8b0e..8e89a33 100644
--- a/gettext-tools/src/xgettext.c
+++ b/gettext-tools/src/xgettext.c
@@ -2289,7 +2289,29 @@ meta information, not the empty string.\n")));
     nitems_before = (mp->comment_dot != NULL ? mp->comment_dot->nitems : 0);
 
     if (extracted_comment != NULL)
-      message_comment_dot_append (mp, extracted_comment);
+      {
+        char *copy = xstrdup (extracted_comment);
+        char *rest;
+
+        rest = copy;
+        while (*rest != '\0')
+          {
+            char *newline = strchr (rest, '\n');
+
+            if (newline != NULL)
+              {
+                *newline = '\0';
+                message_comment_dot_append (mp, rest);
+                rest = newline + 1;
+              }
+            else
+              {
+                message_comment_dot_append (mp, rest);
+                break;
+              }
+          }
+        free (copy);
+      }
 
     add_all_remaining_comments = add_all_comments;
     for (j = 0; ; ++j)
diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog
index 1a0a5e5..ca1c0cc 100644
--- a/gettext-tools/tests/ChangeLog
+++ b/gettext-tools/tests/ChangeLog
@@ -1,3 +1,7 @@
+2013-08-12  Daiki Ueno  <address@hidden>
+
+       * xgettext-glade-7: Add a test for multi-line extracted comments.
+
 2013-08-06  Daiki Ueno  <address@hidden>
 
        xgettext: add support for GSettings schema file
diff --git a/gettext-tools/tests/xgettext-glade-7 
b/gettext-tools/tests/xgettext-glade-7
index 168c8f4..c2d3625 100755
--- a/gettext-tools/tests/xgettext-glade-7
+++ b/gettext-tools/tests/xgettext-glade-7
@@ -67,6 +67,11 @@ cat <<EOF > xg-gl-7.ui
         <col id="1" translatable="yes" context="This is not 
translatable">Please...</col>
         <col id="2">86855555</col>
       </row>
+      <row>
+        <col id="0" translatable="yes" context="First row">Hi</col>
+        <col id="1" translatable="yes" comments="A 
multiline&#10;comment.">Comment</col>
+        <col id="2">999</col>
+      </row>
     </data>
   </object>
   <object class="GtkWindow" id="window">
@@ -187,6 +192,7 @@ EOF
 tmpfiles="$tmpfiles xg-gl-7.pot"
 : ${XGETTEXT=xgettext}
 ${XGETTEXT} -o - xg-gl-7.ui | grep -v 'POT-Creation-Date' > xg-gl-7.pot
+cp xg-gl-7.pot ..
 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
 
 tmpfiles="$tmpfiles xg-gl-7.ok"
@@ -209,13 +215,15 @@ msgstr ""
 "Content-Type: text/plain; charset=CHARSET\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: xg-gl-7.ui:30
+#: xg-gl-7.ui:30 xg-gl-7.ui:45
 msgctxt "First row"
 msgid "Hi"
 msgstr ""
 
 #. A comment.
-#: xg-gl-7.ui:31
+#. A multiline
+#. comment.
+#: xg-gl-7.ui:31 xg-gl-7.ui:46
 msgid "Comment"
 msgstr ""
 
@@ -235,37 +243,37 @@ msgid "Please..."
 msgstr ""
 
 #. This thing is the menu label
-#: xg-gl-7.ui:62
+#: xg-gl-7.ui:67
 msgctxt "Menu"
 msgid "One thing"
 msgstr ""
 
 #. This thing is the label in the inner menu.
-#: xg-gl-7.ui:70
+#: xg-gl-7.ui:75
 msgctxt "One thing"
 msgid "One thing"
 msgstr ""
 
 #. This is easy.
-#: xg-gl-7.ui:87
+#: xg-gl-7.ui:92
 msgctxt "Menu"
 msgid "H_elp"
 msgstr ""
 
 #. This one thing is for the second menu.
-#: xg-gl-7.ui:95
+#: xg-gl-7.ui:100
 msgctxt "Second menu"
 msgid "One thing"
 msgstr ""
 
 #. To you too.
-#: xg-gl-7.ui:105
+#: xg-gl-7.ui:110
 msgctxt "Second menu"
 msgid "Greetings"
 msgstr ""
 
 #. This one thing is the button.
-#: xg-gl-7.ui:142
+#: xg-gl-7.ui:147
 msgctxt "Button"
 msgid "One thing"
 msgstr ""
-- 
1.8.3.1

Regards,
-- 
Daiki Ueno

reply via email to

[Prev in Thread] Current Thread [Next in Thread]