From: Miguel Ángel Arruga Vivas Date: Wed, 13 Mar 2013 17:06:21 +0000 (+0200) Subject: glade: Ignore --extract-all option for Glade2/3. X-Git-Tag: v0.19~172 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf83f72dac7d77d8b3c1f2a7cb17d58cc9a6ae81;p=thirdparty%2Fgettext.git glade: Ignore --extract-all option for Glade2/3. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 538987491..7a8872fff 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,10 @@ +2013-08-13 Miguel Angel Arruga Vivas + + * 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 * 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 d95cd8e48..eebce002d 100644 --- a/gettext-tools/src/x-glade.c +++ b/gettext-tools/src/x-glade.c @@ -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 . 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 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 . 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; diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index ca1c0ccf8..7a12a0147 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 807a63c79..9df133aca 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 cfc770876..b541843f8 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