+2009-05-16 Bruno Haible <bruno@clisp.org>
+
+ Extract comments meant for translators from Glade input files.
+ * xgettext.h (remember_a_message): Add 'extracted_comment' argument.
+ * xgettext.c (remember_a_message): Likewise.
+ (arglist_parser_done): Update.
+ * x-glade.c (struct element_state): Add field 'extracted_comment'.
+ (start_element_handler): Fill it.
+ (end_element_handler): Pass it to 'remember_a_message', free it.
+ * x-awk.c (extract_parenthesized): Update.
+ * x-c.c (extract_parenthesized): Update.
+ * x-csharp.c (extract_parenthesized): Update.
+ * x-elisp.c (read_object): Update.
+ * x-java.c (extract_parenthesized): Update.
+ * x-librep.c (read_object): Update.
+ * x-lisp.c (read_object): Update.
+ * x-perl.c (extract_variable, interpolate_keywords, extract_balanced):
+ Update.
+ * x-php.c (extract_balanced): Update.
+ * x-python.c (extract_balanced): Update.
+ * x-rst.c (extract_rst): Update.
+ * x-scheme.c (read_object): Update.
+ * x-sh.c (read_word, read_command): Update.
+ * x-smalltalk.c (extract_smalltalk): Update.
+ * x-tcl.c (read_command): Update.
+ * x-ycp.c (extract_parenthesized): Update.
+ Reported by <sandro.bonazzola@gmail.com>
+ at <https://savannah.gnu.org/bugs/?26570>.
+
2009-03-29 Bruno Haible <bruno@clisp.org>
* message.h (format_type): New enum value 'format_gfc_internal'.
/* xgettext awk backend.
- Copyright (C) 2002-2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
if (extract_all)
remember_a_message (mlp, NULL, token.string, inner_context, &pos,
- savable_comment);
+ NULL, savable_comment);
else
arglist_parser_remember (argparser, arg, token.string,
inner_context,
pos.line_number = token.line_number;
remember_a_message (mlp, NULL, token.string, inner_context, &pos,
- savable_comment);
+ NULL, savable_comment);
}
next_is_argument = false;
next_context_iter = null_context_list_iterator;
case xgettext_token_type_string_literal:
if (extract_all)
remember_a_message (mlp, NULL, token.string, inner_context,
- &token.pos, token.comment);
+ &token.pos, NULL, token.comment);
else
arglist_parser_remember (argparser, arg, token.string,
inner_context,
/* xgettext C# backend.
- Copyright (C) 2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or modify
xgettext_current_source_encoding = po_charset_utf8;
if (extract_all)
remember_a_message (mlp, NULL, token.string, inner_context,
- &pos, token.comment);
+ &pos, NULL, token.comment);
else
arglist_parser_remember (argparser, arg, token.string,
inner_context,
/* xgettext Emacs Lisp backend.
- Copyright (C) 2001-2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2001-2002.
pos.file_name = logical_file_name;
pos.line_number = op->line_number_at_start;
remember_a_message (mlp, NULL, string_of_object (op),
- null_context, &pos, savable_comment);
+ null_context, &pos, NULL, savable_comment);
}
last_non_comment_line = line_number;
return;
/* xgettext glade backend.
- Copyright (C) 2002-2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
struct element_state
{
bool extract_string;
+ char *extracted_comment;
int lineno;
char *buffer;
size_t bufmax;
p = &stack[stack_depth];
p->extract_string = extract_all;
+ p->extracted_comment = NULL;
/* In Glade 1, a few specific elements are translatable. */
if (!p->extract_string)
p->extract_string =
(hash_find_entry (&keywords, name, strlen (name), &hash_result) == 0);
/* In Glade 2, all <property> and <atkproperty> elements are translatable
- that have the attribute translatable="yes". */
+ that have the attribute translatable="yes".
+ See <http://library.gnome.org/devel/libglade/unstable/libglade-dtd.html>.
+ The translator comment is found in the attribute comments="...".
+ See <http://live.gnome.org/TranslationProject/DevGuidelines/Use comments>.
+ */
if (!p->extract_string
&& (strcmp (name, "property") == 0 || strcmp (name, "atkproperty") == 0))
{
bool has_translatable = false;
+ const char *extracted_comment = NULL;
const char **attp = attributes;
while (*attp != NULL)
{
if (strcmp (attp[0], "translatable") == 0)
- {
- has_translatable = (strcmp (attp[1], "yes") == 0);
- break;
- }
+ has_translatable = (strcmp (attp[1], "yes") == 0);
+ else if (strcmp (attp[0], "comments") == 0)
+ extracted_comment = attp[1];
attp += 2;
}
p->extract_string = has_translatable;
+ p->extracted_comment =
+ (has_translatable && extracted_comment != NULL
+ ? xstrdup (extracted_comment)
+ : NULL);
}
if (!p->extract_string
&& strcmp (name, "atkaction") == 0)
pos.line_number = XML_GetCurrentLineNumber (parser);
remember_a_message (mlp, NULL, xstrdup (attp[1]),
- null_context, &pos, savable_comment);
+ null_context, &pos,
+ NULL, savable_comment);
}
break;
}
pos.line_number = p->lineno;
remember_a_message (mlp, NULL, p->buffer, null_context, &pos,
- savable_comment);
+ p->extracted_comment, savable_comment);
p->buffer = NULL;
}
}
/* Free memory for this stack level. */
+ if (p->extracted_comment != NULL)
+ free (p->extracted_comment);
if (p->buffer != NULL)
free (p->buffer);
/* xgettext Java backend.
- Copyright (C) 2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or modify
xgettext_current_source_encoding = po_charset_utf8;
if (extract_all)
remember_a_message (mlp, NULL, token.string, inner_context,
- &pos, token.comment);
+ &pos, NULL, token.comment);
else
arglist_parser_remember (argparser, arg, token.string,
inner_context,
/* xgettext librep backend.
- Copyright (C) 2001-2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2001.
pos.file_name = logical_file_name;
pos.line_number = op->line_number_at_start;
remember_a_message (mlp, NULL, string_of_object (op),
- null_context, &pos, savable_comment);
+ null_context, &pos, NULL, savable_comment);
}
last_non_comment_line = line_number;
return;
/* xgettext Lisp backend.
- Copyright (C) 2001-2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2001.
pos.file_name = logical_file_name;
pos.line_number = op->line_number_at_start;
remember_a_message (mlp, NULL, string_of_object (op),
- null_context, &pos, savable_comment);
+ null_context, &pos,
+ NULL, savable_comment);
}
last_non_comment_line = line_number;
return;
/* xgettext Perl backend.
- Copyright (C) 2002-2008 Free Software Foundation, Inc.
+ Copyright (C) 2002-2009 Free Software Foundation, Inc.
This file was written by Guido Flohr <guido@imperia.net>, 2002-2003.
xgettext_current_source_encoding = po_charset_utf8;
remember_a_message (mlp, NULL, xstrdup (t1->string),
- context, &pos, savable_comment);
+ context, &pos, NULL, savable_comment);
xgettext_current_source_encoding = xgettext_global_source_encoding;
free_token (t2);
free_token (t1);
extract_quotelike_pass3 (&token, EXIT_FAILURE);
xgettext_current_source_encoding = po_charset_utf8;
remember_a_message (mlp, NULL, token.string, context, &pos,
- savable_comment);
+ NULL, savable_comment);
xgettext_current_source_encoding = xgettext_global_source_encoding;
/* FALLTHROUGH */
default:
pos.line_number = tp->line_number;
xgettext_current_source_encoding = po_charset_utf8;
remember_a_message (mlp, NULL, string, inner_context, &pos,
- tp->comment);
+ NULL, tp->comment);
xgettext_current_source_encoding = xgettext_global_source_encoding;
}
else if (!skip_until_comma)
/* xgettext PHP backend.
- Copyright (C) 2001-2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc.
This file was written by Bruno Haible <bruno@clisp.org>, 2002.
if (extract_all)
remember_a_message (mlp, NULL, token.string, inner_context,
- &pos, token.comment);
+ &pos, NULL, token.comment);
else
arglist_parser_remember (argparser, arg, token.string,
inner_context,
/* xgettext Python backend.
- Copyright (C) 2002-2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
xgettext_current_source_encoding = po_charset_utf8;
if (extract_all)
remember_a_message (mlp, NULL, token.string, inner_context,
- &pos, token.comment);
+ &pos, NULL, token.comment);
else
arglist_parser_remember (argparser, arg, token.string,
inner_context,
/* xgettext RST backend.
- Copyright (C) 2001-2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2001.
pos.file_name = location;
pos.line_number = (size_t)(-1);
- remember_a_message (mlp, NULL, msgid, null_context, &pos, NULL);
+ remember_a_message (mlp, NULL, msgid, null_context, &pos, NULL, NULL);
/* Here c is the last read character: EOF or '\n'. */
if (c == EOF)
/* xgettext Scheme backend.
- Copyright (C) 2004-2008 Free Software Foundation, Inc.
+ Copyright (C) 2004-2009 Free Software Foundation, Inc.
This file was written by Bruno Haible <bruno@clisp.org>, 2004-2005.
pos.file_name = logical_file_name;
pos.line_number = op->line_number_at_start;
remember_a_message (mlp, NULL, string_of_object (op),
- null_context, &pos, savable_comment);
+ null_context, &pos, NULL, savable_comment);
}
last_non_comment_line = line_number;
return;
/* xgettext sh backend.
- Copyright (C) 2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or modify
string.chars[string.charcount++] = (unsigned char) c;
}
remember_a_message (mlp, NULL, string_of_token (&string),
- context, &pos, savable_comment);
+ context, &pos, NULL, savable_comment);
free_token (&string);
error_with_progname = false;
pos.file_name = logical_file_name;
pos.line_number = inner.line_number_at_start;
remember_a_message (mlp, NULL, string_of_word (&inner),
- inner_context, &pos, savable_comment);
+ inner_context, &pos, NULL, savable_comment);
}
}
/* xgettext Smalltalk backend.
- Copyright (C) 2002-2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
pos.file_name = logical_file_name;
pos.line_number = token.line_number;
remember_a_message (mlp, NULL, token.string, null_context,
- &pos, savable_comment);
+ &pos, NULL, savable_comment);
state = 0;
break;
}
pos.line_number = token.line_number;
plural_mp = remember_a_message (mlp, NULL, token.string,
null_context, &pos,
- savable_comment);
+ NULL, savable_comment);
state = 4;
break;
}
/* xgettext Tcl backend.
- Copyright (C) 2002-2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
pos.file_name = logical_file_name;
pos.line_number = inner.line_number_at_start;
remember_a_message (mlp, NULL, string_of_word (&inner),
- inner_context, &pos, savable_comment);
+ inner_context, &pos,
+ NULL, savable_comment);
}
}
/* xgettext YCP backend.
- Copyright (C) 2001-2003, 2005-2008 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2001.
/* Seen an msgid. */
plural_mp = remember_a_message (mlp, NULL, token.string,
inner_context, &pos,
- token.comment);
+ NULL, token.comment);
state = 2;
}
else
message_ty *
remember_a_message (message_list_ty *mlp, char *msgctxt, char *msgid,
flag_context_ty context, lex_pos_ty *pos,
+ const char *extracted_comment,
refcounted_string_list_ty *comment)
{
enum is_format is_format[NFORMATS];
nitems_before = (mp->comment_dot != NULL ? mp->comment_dot->nitems : 0);
+ if (extracted_comment != NULL)
+ message_comment_dot_append (mp, extracted_comment);
+
add_all_remaining_comments = add_all_comments;
for (j = 0; ; ++j)
{
mp = remember_a_message (ap->mlp, best_cp->msgctxt, best_cp->msgid,
msgid_context,
&best_cp->msgid_pos,
- best_cp->msgid_comment);
+ NULL, best_cp->msgid_comment);
if (best_cp->msgid_plural != NULL)
remember_a_message_plural (mp, best_cp->msgid_plural,
msgid_plural_context,
to the callee.
MSGID must be a malloc()ed string; its ownership is passed to the callee.
POS->file_name must be allocated with indefinite extent.
+ EXTRACTED_COMMENT is a comment that needs to be copied into the POT file,
+ or NULL.
COMMENT may be savable_comment, or it may be a saved copy of savable_comment
(then add_reference must be used when saving it, and drop_reference while
dropping it). Clear savable_comment. */
char *msgid,
flag_context_ty context,
lex_pos_ty *pos,
+ const char *extracted_comment,
refcounted_string_list_ty *comment);
+
/* Add an msgid_plural to a message previously returned by
remember_a_message.
STRING must be a malloc()ed string; its ownership is passed to the callee.
xgettext-csharp-4 xgettext-csharp-5 xgettext-csharp-6 \
xgettext-csharp-7 \
xgettext-elisp-1 xgettext-elisp-2 \
- xgettext-glade-1 xgettext-glade-2 xgettext-glade-3 \
+ xgettext-glade-1 xgettext-glade-2 xgettext-glade-3 xgettext-glade-4 \
xgettext-java-1 xgettext-java-2 xgettext-java-3 xgettext-java-4 \
xgettext-java-5 xgettext-java-6 xgettext-java-7 \
xgettext-librep-1 xgettext-librep-2 \