[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gettext] Glade/GtkBuilder related bugs
From: |
Daiki Ueno |
Subject: |
Re: [bug-gettext] Glade/GtkBuilder related bugs |
Date: |
Wed, 30 Jan 2013 16:38:03 +0900 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Hi,
Miguel Ángel <address@hidden> writes:
> I have sent a patch for the bug #34506 that solves the "context"
> problem, but I think that is a first approach, because it looks for it
> in every tag.
Thanks for the patch. A comment and a revised patch are below.
> I will thank any advices if I have to sign anything to contribute with a
> bigger code. I also could help with the refactor of other parsers that I
> have seen you are going to do.
Thanks for your interest. I'll send you the details privately.
> /* Callback called when <element> is seen. */
> static void
> start_element_handler (void *userData, const char *name,
> @@ -429,6 +450,7 @@ start_element_handler (void *userData, const char *name,
> p = &stack[stack_depth];
> p->extract_string = extract_all;
> p->extracted_comment = NULL;
> + p->extracted_context = extract_context (attributes);
Do we really need to extract "context" attribute from every element?
Otherwise, I guess it can be folded in the while-loop below to extract
the translator comments.
>From 6453b69251484860e487e2190be6f5b7b595b124 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?=
<address@hidden>
Date: Wed, 30 Jan 2013 16:21:50 +0900
Subject: [PATCH] Extract message contexts from Glade input files.
---
gettext-tools/src/ChangeLog | 8 ++++++++
gettext-tools/src/x-glade.c | 12 +++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 68da6a6..565e62a 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,11 @@
+2013-01-30 Miguel Ángel Arruga Vivas <address@hidden> (tiny change)
+
+ Extract message contexts from Glade input files.
+ Reported at <https://savannah.gnu.org/bugs/?34506>
+ * x-glade.c (struct element_state): Add field 'extracted_context'.
+ (start_element_handler): Extract "context" attribute.
+ (end_element_handler): Respect p->extracted_context.
+
2013-01-09 Andreas Stricker <address@hidden> (tiny change)
* po-xerror.c: Include error.h for error_message_count.
diff --git a/gettext-tools/src/x-glade.c b/gettext-tools/src/x-glade.c
index 11f8397..e3167c5 100644
--- a/gettext-tools/src/x-glade.c
+++ b/gettext-tools/src/x-glade.c
@@ -386,6 +386,7 @@ struct element_state
{
bool extract_string;
char *extracted_comment;
+ char *extracted_context;
int lineno;
char *buffer;
size_t bufmax;
@@ -429,6 +430,7 @@ start_element_handler (void *userData, const char *name,
p = &stack[stack_depth];
p->extract_string = extract_all;
p->extracted_comment = NULL;
+ p->extracted_context = NULL;
/* In Glade 1, a few specific elements are translatable. */
if (!p->extract_string)
p->extract_string =
@@ -444,6 +446,7 @@ start_element_handler (void *userData, const char *name,
{
bool has_translatable = false;
const char *extracted_comment = NULL;
+ const char *extracted_context = NULL;
const char **attp = attributes;
while (*attp != NULL)
{
@@ -451,6 +454,8 @@ start_element_handler (void *userData, const char *name,
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;
@@ -458,6 +463,10 @@ start_element_handler (void *userData, const char *name,
(has_translatable && extracted_comment != NULL
? xstrdup (extracted_comment)
: NULL);
+ p->extracted_context =
+ (has_translatable && extracted_context != NULL
+ ? xstrdup (extracted_context)
+ : NULL);
}
if (!p->extract_string
&& strcmp (name, "atkaction") == 0)
@@ -512,7 +521,8 @@ end_element_handler (void *userData, const char *name)
pos.file_name = logical_file_name;
pos.line_number = p->lineno;
- remember_a_message (mlp, NULL, p->buffer, null_context, &pos,
+ remember_a_message (mlp, p->extracted_context, p->buffer,
+ null_context, &pos,
p->extracted_comment, savable_comment);
p->buffer = NULL;
}
--
1.8.1
- [bug-gettext] Glade/GtkBuilder related bugs, Miguel Ángel, 2013/01/25
- Re: [bug-gettext] Glade/GtkBuilder related bugs,
Daiki Ueno <=
- Re: [bug-gettext] Glade/GtkBuilder related bugs, Miguel Ángel, 2013/01/30
- Re: [bug-gettext] Glade/GtkBuilder related bugs, Daiki Ueno, 2013/01/30
- [bug-gettext] [Patch 1/1] Savannah bug #36063, Miguel Ángel, 2013/01/31
- Re: [bug-gettext] Glade/GtkBuilder related bugs, Miguel Ángel, 2013/01/31
- [bug-gettext] [Patch 1/2] Glade/GtkBuilder related bugs, Miguel Ángel, 2013/01/31
- Re: [bug-gettext] [Patch 2/2] Glade/GtkBuilder related bugs, Miguel Ángel, 2013/01/31