>From 86a9ab7225a70d8b7ed7ffca9391fc95225a6759 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?=
Date: Tue, 13 Aug 2013 07:32:11 +0200
Subject: [PATCH] glade: Ignore --extract-all option for Glade2/3.
---
gettext-tools/src/ChangeLog | 5 ++++
gettext-tools/src/x-glade.c | 53 +++++++++++++++-------------------
gettext-tools/tests/ChangeLog | 5 ++++
gettext-tools/tests/xgettext-glade-5 | 15 ++++++++++
gettext-tools/tests/xgettext-glade-6 | 12 ++++++++
5 files changed, 61 insertions(+), 29 deletions(-)
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 5389874..72cb607 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,8 @@
+2013-08-13 Miguel Angel Arruga Vivas
+
+ * x-glade.c (start_element_glade2): Ignore extract-all option.
+ (start_element_gtkbuilder): Likewise.
+
2013-08-12 Daiki Ueno
* xgettext.c (remember_a_message): Handle multi-line extracted
diff --git a/gettext-tools/src/x-glade.c b/gettext-tools/src/x-glade.c
index d95cd8e..673bcf0 100644
--- a/gettext-tools/src/x-glade.c
+++ b/gettext-tools/src/x-glade.c
@@ -219,8 +219,7 @@ start_element_glade2 (struct element_state *p, const char *name,
See .
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 +245,7 @@ start_element_glade2 (struct element_state *p, const char *name,
/* In Glade 2, the attribute description="..." of
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 +323,29 @@ start_element_gtkbuilder (struct element_state *p, const char *name,
See .
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
diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog
index ca1c0cc..7a12a01 100644
--- a/gettext-tools/tests/ChangeLog
+++ b/gettext-tools/tests/ChangeLog
@@ -1,3 +1,8 @@
+2013-08-13 Miguel Angel Arruga Vivas
+
+ * xgettext-glade-5: Add a test for --extract-all option behavior.
+ * xgettext-glade-6: Likewise.
+
2013-08-12 Daiki Ueno
* xgettext-glade-7: Add a test for multi-line extracted comments.
diff --git a/gettext-tools/tests/xgettext-glade-5 b/gettext-tools/tests/xgettext-glade-5
index 807a63c..9df133a 100755
--- a/gettext-tools/tests/xgettext-glade-5
+++ b/gettext-tools/tests/xgettext-glade-5
@@ -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 < xg-gl-5b.glade
diff --git a/gettext-tools/tests/xgettext-glade-6 b/gettext-tools/tests/xgettext-glade-6
index cfc7708..b541843 100755
--- a/gettext-tools/tests/xgettext-glade-6
+++ b/gettext-tools/tests/xgettext-glade-6
@@ -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
--
1.7.10.4