Hi to all,

This patch fixes Glade 2 and 3 context and comments extraction in the
presence of the --extract-all command line option. Also it could be
ignored if It is the desired behaviour. Any comment is welcome.

Happy Hacking!
Miguel
>From 29bde823435396763372c8c8d8171b306aba9e7e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?= <[email protected]>
Date: Sun, 11 Aug 2013 17:29:39 +0200
Subject: [PATCH] x-glade: Fix --extract-all option.

---
 gettext-tools/src/ChangeLog |    6 ++++++
 gettext-tools/src/x-glade.c |   45 +++++++++++++++++++------------------------
 2 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 4060a37..5f4e5a7 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,5 +1,11 @@
 2013-08-11  Miguel Angel Arruga Vivas  <[email protected]>
 
+	* x-glade.c (start_element_glade2): Extract comments and context
+	with --extract-all option.
+	(start_element_gtkbuilder): Likewise.
+
+2013-08-11  Miguel Angel Arruga Vivas  <[email protected]>
+
 	* x-glade.c (struct element_state): Remove field extracted_comment.
 	(comment_handler): Add foward declaration.
 	(start_element_glade2): Call comment_handler.
diff --git a/gettext-tools/src/x-glade.c b/gettext-tools/src/x-glade.c
index 7a6124e..4196415 100644
--- a/gettext-tools/src/x-glade.c
+++ b/gettext-tools/src/x-glade.c
@@ -221,8 +221,7 @@ start_element_glade2 (struct element_state *p, const char *name,
      See <http://live.gnome.org/TranslationProject/DevGuidelines/Use comments>.
      If the element has the attribute context="yes", the content of
      the element is in the form "msgctxt|msgid".  */
-  if (!p->extract_string
-      && (strcmp (name, "property") == 0 || strcmp (name, "atkproperty") == 0))
+  if (strcmp (name, "property") == 0 || strcmp (name, "atkproperty") == 0)
     {
       bool has_translatable = false;
       bool has_context = false;
@@ -237,14 +236,13 @@ start_element_glade2 (struct element_state *p, const char *name,
             has_context = (strcmp (attp[1], "yes") == 0);
           attp += 2;
         }
-      p->extract_string = has_translatable;
+      p->extract_string = p->extract_string || has_translatable;
       p->extract_context = has_context;
     }
 
   /* In Glade 2, the attribute description="..." of <atkaction>
      element is also translatable.  */
-  if (!p->extract_string
-      && strcmp (name, "atkaction") == 0)
+  if (strcmp (name, "atkaction") == 0)
     {
       const char **attp = attributes;
       while (*attp != NULL)
@@ -322,27 +320,24 @@ start_element_gtkbuilder (struct element_state *p, const char *name,
      See <https://developer.gnome.org/gtk3/stable/GtkBuilder.html#BUILDER-UI>.
      The translator comment is found in the attribute comments="..."
      and context is found in the attribute context="...".  */
-  if (!p->extract_string)
+  bool has_translatable = false;
+  const char *extracted_context = NULL;
+  const char **attp = attributes;
+  while (*attp != NULL)
     {
-      bool has_translatable = false;
-      const char *extracted_context = NULL;
-      const char **attp = attributes;
-      while (*attp != NULL)
-        {
-          if (strcmp (attp[0], "translatable") == 0)
-            has_translatable = (strcmp (attp[1], "yes") == 0);
-          else if (strcmp (attp[0], "comments") == 0)
-            comment_handler (NULL, attp[1]);
-          else if (strcmp (attp[0], "context") == 0)
-            extracted_context = attp[1];
-          attp += 2;
-        }
-      p->extract_string = has_translatable;
-      p->extracted_context =
-        (has_translatable && extracted_context != NULL
-         ? xstrdup (extracted_context)
-         : NULL); 
-   }
+      if (strcmp (attp[0], "translatable") == 0)
+        has_translatable = (strcmp (attp[1], "yes") == 0);
+      else if (strcmp (attp[0], "comments") == 0)
+        comment_handler (NULL, attp[1]);
+      else if (strcmp (attp[0], "context") == 0)
+        extracted_context = attp[1];
+      attp += 2;
+    }
+  p->extract_string = p->extract_string || has_translatable;
+  p->extracted_context =
+    (has_translatable && extracted_context != NULL
+     ? xstrdup (extracted_context)
+     : NULL);
 }
 
 static void
-- 
1.7.10.4

Reply via email to