]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
glade: Ignore --extract-all option for Glade2/3.
authorMiguel Ángel Arruga Vivas <rosen644835@gmail.com>
Wed, 13 Mar 2013 17:06:21 +0000 (19:06 +0200)
committerMiguel Ángel Arruga Vivas <rosen644835@gmail.com>
Tue, 13 Aug 2013 17:06:21 +0000 (19:06 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/x-glade.c
gettext-tools/tests/ChangeLog
gettext-tools/tests/xgettext-glade-5
gettext-tools/tests/xgettext-glade-6

index 538987491655a8d24b86aeb0c45283ba82feb9d5..7a8872fff57041435c4c392eb814443c6577fc4d 100644 (file)
@@ -1,3 +1,10 @@
+2013-08-13  Miguel Angel Arruga Vivas  <rosen644835@gmail.com>
+
+       * x-glade.c (start_element_glade1): Use extract_all variable.
+       (start_element_glade2): Ignore --extract-all option.
+       (start_element_gtkbuilder): Likewise.
+       (start_element_handler): Initialize p->extract_string to false.
+
 2013-08-12  Daiki Ueno  <ueno@gnu.org>
 
        * xgettext.c (remember_a_message): Handle multi-line extracted
index d95cd8e488d3524f9b4fdc1eeab279fc6bade760..eebce002d95f87f9cec9302b77d7dce0ed72318c 100644 (file)
@@ -185,7 +185,9 @@ start_element_glade1 (struct element_state *p, const char *name,
 {
   void *hash_result;
 
-  /* In Glade 1, a few specific elements are translatable.  */
+  /* In Glade 1, a few specific elements are translatable without
+     --extract-all option.  */
+  p->extract_string = extract_all;
   if (!p->extract_string)
     p->extract_string =
       (hash_find_entry (&keywords, name, strlen (name), &hash_result) == 0);
@@ -219,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;
@@ -246,8 +247,7 @@ start_element_glade2 (struct element_state *p, const char *name,
 
   /* 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)
@@ -325,32 +325,29 @@ 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_comment = NULL;
+  const char *extracted_context = NULL;
+  const char **attp = attributes;
+  while (*attp != NULL)
     {
-      bool has_translatable = false;
-      const char *extracted_comment = NULL;
-      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)
-            extracted_comment = attp[1];
-          else if (strcmp (attp[0], "context") == 0)
-            extracted_context = attp[1];
-          attp += 2;
-        }
-      p->extract_string = has_translatable;
-      p->extracted_comment =
-        (has_translatable && extracted_comment != NULL
-         ? xstrdup (extracted_comment)
-         : NULL);
-      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)
+        extracted_comment = attp[1];
+      else if (strcmp (attp[0], "context") == 0)
+        extracted_context = attp[1];
+      attp += 2;
+    }
+  p->extract_string = has_translatable;
+  p->extracted_comment =
+    (has_translatable && extracted_comment != NULL
+     ? xstrdup (extracted_comment)
+     : NULL);
+  p->extracted_context =
+    (has_translatable && extracted_context != NULL
+     ? xstrdup (extracted_context)
+     : NULL);
 }
 
 static void
@@ -432,7 +429,7 @@ The root element <%s> is not allowed in a valid Glade file"),
   stack[stack_depth - 1].extract_string = false;
 
   p = &stack[stack_depth];
-  p->extract_string = extract_all;
+  p->extract_string = false;
   p->extract_context = false;
   p->extracted_comment = NULL;
   p->extracted_context = NULL;
index ca1c0ccf84d54154629dd238f011e8b8064f7e1e..7a12a0147edde51aa6e08e2cc90f79620f327eb3 100644 (file)
@@ -1,3 +1,8 @@
+2013-08-13  Miguel Angel Arruga Vivas  <rosen644835@gmail.com>
+
+       * xgettext-glade-5: Add a test for --extract-all option behavior.
+       * xgettext-glade-6: Likewise.
+
 2013-08-12  Daiki Ueno  <ueno@gnu.org>
 
        * xgettext-glade-7: Add a test for multi-line extracted comments.
index 807a63c79bec554179585b955838d3d437e43956..9df133aca599b3c2df56a1d24dd873ae1c05eb8d 100755 (executable)
@@ -105,6 +105,21 @@ test $result = 0 || {
   rm -fr $tmpfiles; exit $result
 }
 
+# Check with --extract-all option
+rm xg-gl-5.tmp
+${XGETTEXT} -a -o xg-gl-5.tmp xg-gl-5.glade
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+# Don't simplify this to "grep ... < xg-gl-5.tmp", otherwise OpenBSD 4.0 grep
+# only outputs "Binary file (standard input) matches".
+cat xg-gl-5.tmp | grep -v 'POT-Creation-Date' > xg-gl-5.pot
+
+${DIFF} xg-gl-5.ok xg-gl-5.pot
+result=$?
+
+test $result = 0 || {
+  rm -fr $tmpfiles; exit $result
+}
+
 tmpfiles="$tmpfiles xg-gl-5b.glade"
 cat <<EOF > xg-gl-5b.glade
 <?xml version="1.0"?>
index cfc7708767dc7475167ca8e5c0176cba1a74bc50..b541843f8c6d251807f388c6582396472162ea43 100755 (executable)
@@ -73,6 +73,18 @@ EOF
 ${DIFF} xg-gl-6.ok xg-gl-6.pot
 result=$?
 
+test $result = 0 || {
+  rm -fr $tmpfiles; exit $result
+}
+
+# Check with --extract-all option.
+${XGETTEXT} -a -o - xg-gl-6.ui | grep -v 'POT-Creation-Date' > xg-gl-6.pot
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+# Must be ignored.
+${DIFF} xg-gl-6.ok xg-gl-6.pot
+result=$?
+
 rm -fr $tmpfiles
 
 exit $result