[gnumeric] Help: fix translation domain confusion.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] Help: fix translation domain confusion.
- Date: Fri, 10 Jul 2009 00:30:34 +0000 (UTC)
commit 61cf619e2e40469c877a5b4e9821970f3da724f8
Author: Morten Welinder <terra gnome org>
Date: Thu Jul 9 20:29:29 2009 -0400
Help: fix translation domain confusion.
ChangeLog | 6 +++
NEWS | 1 +
plugins/guile/plugin.c | 2 +-
src/dialogs/ChangeLog | 5 ++
src/dialogs/dialog-function-select.c | 17 +++----
src/func-builtin.c | 11 +++--
src/func.c | 24 +++++++---
src/func.h | 9 +++-
src/gnm-plugin.c | 83 +++++++++++++++++++--------------
9 files changed, 98 insertions(+), 60 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index eb1260c..d61d6d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2009-07-09 Morten Welinder <terra gnome org>
+ * src/gnm-plugin.c (plugin_service_function_group_read_xml):
+ Extract textdomain from xml.
+
+ * src/func.c (gnm_func_add, gnm_func_add_stub): Add new
+ "textdomain" paramter. All callers changed.
+
* src/gnumeric-gconf.c: Transparently watch all configuration
options of types int, bool, double, and string.
diff --git a/NEWS b/NEWS
index 3580a65..9443e3f 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,7 @@ Morten:
* Convert fn-logical and sample_datasource to new help format.
* Fix problem with print area.
* Fix problems with in-sheet combos. [#587992]
+ * Fix translation textdomain confusion. [#588110]
--------------------------------------------------------------------------
Gnumeric 1.9.9
diff --git a/plugins/guile/plugin.c b/plugins/guile/plugin.c
index 2145a88..9f1c878 100644
--- a/plugins/guile/plugin.c
+++ b/plugins/guile/plugin.c
@@ -205,7 +205,7 @@ scm_register_function (SCM scm_name, SCM scm_args, SCM scm_help, SCM scm_categor
desc.test_status = GNM_FUNC_TEST_STATUS_UNKNOWN;
cat = gnm_func_group_fetch (SCM_CHARS (scm_category), NULL);
- fndef = gnm_func_add (cat, &desc);
+ fndef = gnm_func_add (cat, &desc, NULL);
gnm_func_set_user_data (fndef, GINT_TO_POINTER (scm_function));
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 08b4be7..3161159 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-09 Morten Welinder <terra gnome org>
+
+ * dialog-function-select.c (describe_new_style): Translate in the
+ right textdomain.
+
2009-07-02 Morten Welinder <terra gnome org>
* dialog-function-select.c (make_expr_example): Allow array
diff --git a/src/dialogs/dialog-function-select.c b/src/dialogs/dialog-function-select.c
index cd6a5d2..db8f109 100644
--- a/src/dialogs/dialog-function-select.c
+++ b/src/dialogs/dialog-function-select.c
@@ -45,8 +45,7 @@
#include <gtk/gtk.h>
#include <string.h>
-#undef F_
-#define F_(s) dgettext ("gnumeric-functions", (s))
+#define F2(func,s) dgettext ((func)->textdomain->str, (s))
#define FUNCTION_SELECT_KEY "function-selector-dialog"
#define FUNCTION_SELECT_DIALOG_KEY "function-selector-dialog"
@@ -476,7 +475,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
for (help = func->help; 1; help++) {
switch (help->type) {
case GNM_FUNC_HELP_NAME: {
- const char *text = F_(help->text);
+ const char *text = F2 (func, help->text);
const char *colon = strchr (text, ':');
if (!colon)
break;
@@ -487,7 +486,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
break;
}
case GNM_FUNC_HELP_ARG: {
- const char *text = F_(help->text);
+ const char *text = F2 (func, help->text);
const char *colon = strchr (text, ':');
if (!colon)
break;
@@ -505,14 +504,14 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
break;
}
case GNM_FUNC_HELP_DESCRIPTION: {
- const char *text = F_(help->text);
+ const char *text = F2 (func, help->text);
ADD_TEXT ("\n");
ADD_TEXT_WITH_ARGS (text);
ADD_TEXT ("\n");
break;
}
case GNM_FUNC_HELP_NOTE: {
- const char *text = F_(help->text);
+ const char *text = F2 (func, help->text);
ADD_TEXT ("\n");
ADD_TEXT (_("Note: "));
ADD_TEXT_WITH_ARGS (text);
@@ -520,7 +519,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
break;
}
case GNM_FUNC_HELP_EXAMPLES: {
- const char *text = F_(help->text);
+ const char *text = F2 (func, help->text);
gboolean was_translated = (text != help->text);
if (!seen_examples) {
@@ -600,7 +599,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
break;
}
case GNM_FUNC_HELP_EXCEL: {
- const char *text = F_(help->text);
+ const char *text = F2 (func, help->text);
ADD_TEXT ("\n");
ADD_TEXT (_("Microsoft Excel: "));
ADD_TEXT_WITH_ARGS (text);
@@ -608,7 +607,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func, Sheet *shee
break;
}
case GNM_FUNC_HELP_ODF: {
- const char *text = F_(help->text);
+ const char *text = F2 (func, help->text);
ADD_TEXT ("\n");
ADD_TEXT (_("ODF (OpenFormula): "));
ADD_TEXT_WITH_ARGS (text);
diff --git a/src/func-builtin.c b/src/func-builtin.c
index a7eed88..d73c852 100644
--- a/src/func-builtin.c
+++ b/src/func-builtin.c
@@ -341,6 +341,7 @@ void
func_builtin_init (void)
{
const char *gname;
+ const char *textdomain = GETTEXT_PACKAGE;
static GnmFuncDescriptor const builtins [] = {
{ "sum", NULL, N_("number,number,"),
@@ -379,17 +380,17 @@ func_builtin_init (void)
gname = N_("Mathematics");
math_group = gnm_func_group_fetch (gname, _(gname));
- gnm_func_add (math_group, builtins + 0);
- gnm_func_add (math_group, builtins + 1);
+ gnm_func_add (math_group, builtins + 0, textdomain);
+ gnm_func_add (math_group, builtins + 1, textdomain);
gname = N_("Gnumeric");
gnumeric_group = gnm_func_group_fetch (gname, _(gname));
- gnm_func_add (gnumeric_group, builtins + 2);
- gnm_func_add (gnumeric_group, builtins + 3);
+ gnm_func_add (gnumeric_group, builtins + 2, textdomain);
+ gnm_func_add (gnumeric_group, builtins + 3, textdomain);
gname = N_("Logic");
logic_group = gnm_func_group_fetch (gname, _(gname));
- gnm_func_add (logic_group, builtins + 4);
+ gnm_func_add (logic_group, builtins + 4, textdomain);
}
static void
diff --git a/src/func.c b/src/func.c
index 31e5b58..8ceaefa 100644
--- a/src/func.c
+++ b/src/func.c
@@ -690,6 +690,10 @@ gnm_func_free (GnmFunc *func)
g_free (func->fn.args.arg_types);
if (func->flags & GNM_FUNC_FREE_NAME)
g_free ((char *)func->name);
+
+ if (func->textdomain)
+ go_string_unref (func->textdomain);
+
g_free (func);
}
@@ -727,7 +731,8 @@ gnm_func_lookup (char const *name, Workbook *scope)
GnmFunc *
gnm_func_add (GnmFuncGroup *fn_group,
- GnmFuncDescriptor const *desc)
+ GnmFuncDescriptor const *desc,
+ const char *textdomain)
{
static char const valid_tokens[] = "fsbraAES?|";
GnmFunc *func;
@@ -737,12 +742,14 @@ gnm_func_add (GnmFuncGroup *fn_group,
g_return_val_if_fail (desc != NULL, NULL);
func = g_new (GnmFunc, 1);
- if (func == NULL)
- return NULL;
+
+ if (!textdomain)
+ textdomain = GETTEXT_PACKAGE;
func->name = desc->name;
func->arg_names = desc->arg_names;
func->help = desc->help ? desc->help : NULL;
+ func->textdomain = go_string_new (textdomain);
func->linker = desc->linker;
func->unlinker = desc->unlinker;
func->ref_notify = desc->ref_notify;
@@ -797,18 +804,21 @@ unknownFunctionHandler (GnmFuncEvalInfo *ei,
GnmFunc *
gnm_func_add_stub (GnmFuncGroup *fn_group,
- char const *name,
+ const char *name,
+ const char *textdomain,
GnmFuncLoadDesc load_desc,
GnmFuncRefNotify opt_ref_notify)
{
GnmFunc *func = g_new0 (GnmFunc, 1);
- if (func == NULL)
- return NULL;
+
+ if (!textdomain)
+ textdomain = GETTEXT_PACKAGE;
func->name = name;
func->ref_notify = opt_ref_notify;
func->fn_type = GNM_FUNC_TYPE_STUB;
func->fn.load_desc = load_desc;
+ func->textdomain = go_string_new (textdomain);
func->fn_group = fn_group;
if (fn_group != NULL)
@@ -861,7 +871,7 @@ gnm_func_add_placeholder (Workbook *scope,
/* WISHLIST : it would be nice to have a log if these. */
g_warning ("Unknown %sfunction : %s", type, name);
- func = gnm_func_add (unknown_cat, &desc);
+ func = gnm_func_add (unknown_cat, &desc, NULL);
if (scope != NULL) {
if (scope->sheet_local_functions == NULL)
diff --git a/src/func.h b/src/func.h
index a7ab3bc..664a2ae 100644
--- a/src/func.h
+++ b/src/func.h
@@ -194,6 +194,7 @@ struct _GnmFunc {
char const *name;
char const *arg_names;
GnmFuncHelp const *help;
+ GOString *textdomain;
GnmFuncType fn_type;
union {
GnmFuncNodes nodes;
@@ -232,10 +233,12 @@ gpointer gnm_func_get_user_data (GnmFunc const *func);
void gnm_func_set_user_data (GnmFunc *func, gpointer user_data);
GnmFunc *gnm_func_lookup (char const *name, Workbook *scope); /* change scope one day */
GnmFunc *gnm_func_add (GnmFuncGroup *group,
- GnmFuncDescriptor const *descriptor);
+ GnmFuncDescriptor const *descriptor,
+ const char *textdomain);
GnmFunc *gnm_func_add_stub (GnmFuncGroup *group,
- char const *name,
- GnmFuncLoadDesc load_desc,
+ const char *name,
+ const char *textdomain,
+ GnmFuncLoadDesc load_desc,
GnmFuncRefNotify opt_ref_notify);
GnmFunc *gnm_func_add_placeholder (Workbook *optional_scope, /* change scope one day */
char const *name,
diff --git a/src/gnm-plugin.c b/src/gnm-plugin.c
index 6bda4ee..de06310 100644
--- a/src/gnm-plugin.c
+++ b/src/gnm-plugin.c
@@ -27,22 +27,28 @@ struct _PluginServiceFunctionGroup {
gchar *category_name, *translated_category_name;
GSList *function_name_list;
- GnmFuncGroup *func_group;
+ GnmFuncGroup *func_group;
PluginServiceFunctionGroupCallbacks cbs;
+ char *textdomain;
};
static void
plugin_service_function_group_finalize (GObject *obj)
{
- PluginServiceFunctionGroup *service_function_group = GNM_PLUGIN_SERVICE_FUNCTION_GROUP (obj);
+ PluginServiceFunctionGroup *sfg = GNM_PLUGIN_SERVICE_FUNCTION_GROUP (obj);
GObjectClass *parent_class;
- g_free (service_function_group->category_name);
- service_function_group->category_name = NULL;
- g_free (service_function_group->translated_category_name);
- service_function_group->translated_category_name = NULL;
- go_slist_free_custom (service_function_group->function_name_list, g_free);
- service_function_group->function_name_list = NULL;
+ g_free (sfg->category_name);
+ sfg->category_name = NULL;
+
+ g_free (sfg->translated_category_name);
+ sfg->translated_category_name = NULL;
+
+ go_slist_free_custom (sfg->function_name_list, g_free);
+ sfg->function_name_list = NULL;
+
+ g_free (sfg->textdomain);
+ sfg->textdomain = NULL;
parent_class = g_type_class_peek (GO_TYPE_PLUGIN_SERVICE);
parent_class->finalize (obj);
@@ -54,14 +60,13 @@ plugin_service_function_group_read_xml (GOPluginService *service, xmlNode *tree,
xmlNode *category_node, *translated_category_node, *functions_node;
gchar *category_name, *translated_category_name;
GSList *function_name_list = NULL;
+ gchar *textdomain = NULL;
GO_INIT_RET_ERROR_INFO (ret_error);
category_node = e_xml_get_child_by_name_no_lang (tree, "category");
if (category_node != NULL) {
- xmlChar *val;
-
- val = xmlNodeGetContent (category_node);
- category_name = g_strdup ((gchar *)val);
+ xmlChar *val = xmlNodeGetContent (category_node);
+ category_name = g_strdup (CXML2C (val));
xmlFree (val);
} else {
category_name = NULL;
@@ -75,7 +80,7 @@ plugin_service_function_group_read_xml (GOPluginService *service, xmlNode *tree,
xmlChar *val;
val = xmlNodeGetContent (translated_category_node);
- translated_category_name = g_strdup ((gchar *)val);
+ translated_category_name = g_strdup (CXML2C (val));
xmlFree (val);
g_free (lang);
} else {
@@ -88,6 +93,8 @@ plugin_service_function_group_read_xml (GOPluginService *service, xmlNode *tree,
if (functions_node != NULL) {
xmlNode *node;
+ textdomain = xml_node_get_cstr (functions_node, "textdomain");
+
for (node = functions_node->xmlChildrenNode; node != NULL; node = node->next) {
gchar *func_name;
@@ -100,11 +107,12 @@ plugin_service_function_group_read_xml (GOPluginService *service, xmlNode *tree,
GO_SLIST_REVERSE (function_name_list);
}
if (category_name != NULL && function_name_list != NULL) {
- PluginServiceFunctionGroup *service_function_group = GNM_PLUGIN_SERVICE_FUNCTION_GROUP (service);
+ PluginServiceFunctionGroup *sfg = GNM_PLUGIN_SERVICE_FUNCTION_GROUP (service);
- service_function_group->category_name = category_name;
- service_function_group->translated_category_name = translated_category_name;
- service_function_group->function_name_list = function_name_list;
+ sfg->category_name = category_name;
+ sfg->translated_category_name = translated_category_name;
+ sfg->function_name_list = function_name_list;
+ sfg->textdomain = textdomain;
} else {
GSList *error_list = NULL;
@@ -122,6 +130,8 @@ plugin_service_function_group_read_xml (GOPluginService *service, xmlNode *tree,
g_free (category_name);
g_free (translated_category_name);
go_slist_free_custom (function_name_list, g_free);
+
+ g_free (textdomain);
}
}
@@ -129,8 +139,8 @@ static gboolean
plugin_service_function_group_func_desc_load (GnmFunc const *fn_def,
GnmFuncDescriptor *res)
{
- GOPluginService *service = gnm_func_get_user_data (fn_def);
- PluginServiceFunctionGroup *service_function_group = GNM_PLUGIN_SERVICE_FUNCTION_GROUP (service);
+ GOPluginService *service = gnm_func_get_user_data (fn_def);
+ PluginServiceFunctionGroup *sfg = GNM_PLUGIN_SERVICE_FUNCTION_GROUP (service);
ErrorInfo *error = NULL;
g_return_val_if_fail (fn_def != NULL, FALSE);
@@ -141,14 +151,15 @@ plugin_service_function_group_func_desc_load (GnmFunc const *fn_def,
error_info_free (error);
return FALSE;
}
- if (NULL == service_function_group->cbs.func_desc_load) {
+ if (NULL == sfg->cbs.func_desc_load) {
error = error_info_new_printf (_("No func_desc_load method.\n"));
error_info_print (error);
error_info_free (error);
return FALSE;
}
- return service_function_group->cbs.func_desc_load (service,
- gnm_func_get_name (fn_def), res);
+ return sfg->cbs.func_desc_load (service,
+ gnm_func_get_name (fn_def),
+ res);
}
static void
@@ -168,17 +179,17 @@ plugin_service_function_group_func_ref_notify (GnmFunc *fn_def, int refcount)
static void
plugin_service_function_group_activate (GOPluginService *service, ErrorInfo **ret_error)
{
- PluginServiceFunctionGroup *service_function_group = GNM_PLUGIN_SERVICE_FUNCTION_GROUP (service);
+ PluginServiceFunctionGroup *sfg =
+ GNM_PLUGIN_SERVICE_FUNCTION_GROUP (service);
GO_INIT_RET_ERROR_INFO (ret_error);
- service_function_group->func_group = gnm_func_group_fetch (
- service_function_group->category_name,
- service_function_group->translated_category_name);
- GO_SLIST_FOREACH (service_function_group->function_name_list, char, fname,
+ sfg->func_group = gnm_func_group_fetch (sfg->category_name,
+ sfg->translated_category_name);
+ GO_SLIST_FOREACH (sfg->function_name_list, char, fname,
GnmFunc *fn_def;
fn_def = gnm_func_add_stub (
- service_function_group->func_group, fname,
+ sfg->func_group, fname, sfg->textdomain,
plugin_service_function_group_func_desc_load,
plugin_service_function_group_func_ref_notify);
gnm_func_set_user_data (fn_def, service);
@@ -189,10 +200,10 @@ plugin_service_function_group_activate (GOPluginService *service, ErrorInfo **re
static void
plugin_service_function_group_deactivate (GOPluginService *service, ErrorInfo **ret_error)
{
- PluginServiceFunctionGroup *service_function_group = GNM_PLUGIN_SERVICE_FUNCTION_GROUP (service);
+ PluginServiceFunctionGroup *sfg = GNM_PLUGIN_SERVICE_FUNCTION_GROUP (service);
GO_INIT_RET_ERROR_INFO (ret_error);
- GO_SLIST_FOREACH (service_function_group->function_name_list, char, fname,
+ GO_SLIST_FOREACH (sfg->function_name_list, char, fname,
gnm_func_free (gnm_func_lookup (fname, NULL));
);
service->is_active = FALSE;
@@ -201,14 +212,14 @@ plugin_service_function_group_deactivate (GOPluginService *service, ErrorInfo **
static char *
plugin_service_function_group_get_description (GOPluginService *service)
{
- PluginServiceFunctionGroup *service_function_group = GNM_PLUGIN_SERVICE_FUNCTION_GROUP (service);
+ PluginServiceFunctionGroup *sfg = GNM_PLUGIN_SERVICE_FUNCTION_GROUP (service);
int n_functions;
char const *category_name;
- n_functions = g_slist_length (service_function_group->function_name_list);
- category_name = service_function_group->translated_category_name != NULL
- ? service_function_group->translated_category_name
- : service_function_group->category_name;
+ n_functions = g_slist_length (sfg->function_name_list);
+ category_name = sfg->translated_category_name != NULL
+ ? sfg->translated_category_name
+ : sfg->category_name;
return g_strdup_printf (ngettext (
"%d function in category \"%s\"",
@@ -225,7 +236,9 @@ plugin_service_function_group_init (PluginServiceFunctionGroup *s)
s->translated_category_name = NULL;
s->function_name_list = NULL;
s->func_group = NULL;
+ s->textdomain = NULL;
}
+
static void
plugin_service_function_group_class_init (GObjectClass *gobject_class)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]