translate branches on the fly, get rid of dummy_entries

--Sven
This commit is contained in:
Sven Neumann 2000-02-26 19:09:28 +00:00
parent 8769bbb456
commit e477d76b48
9 changed files with 272 additions and 168 deletions

View file

@ -1,5 +1,26 @@
Sat Feb 26 19:56:35 CET 2000 Sven Neumann <sven@gimp.org>
Daniel Egger <Daniel.Egger@suse.de>
* app/menus.c: Branches are now translated on the fly by using
the translation of the menu_entry that causes the menu to be
created. This has the drawback that this menu needs to have a
proper translation or the branch won't be translated, but we
don't need the dummy_entries any more and plugins can provide
deeply nested menus that are translated from one string.
* plug-ins/gap/gap_frontends_main.c
* plug-ins/script-fu/script-fu.c
* plug-ins/webbrowser/webbrowser.c: removed the dummy entries
The translation of Script-Fu is the remaining problem. IMHO we
should solve this properly by writing a xgettext-like script
that parses the Script-Fus and add a gimp-script-fu domain.
With trivial changes to script-fu-scripts.c we will get a
completely internationalized Script-Fu UI.
2000-02-26 Garry R. Osgood <gosgood@idt.net> 2000-02-26 Garry R. Osgood <gosgood@idt.net>
* app/commands.c
* app/commands.c
* app/gimpimage.c * app/gimpimage.c
* app/layer.c * app/layer.c
* app/layer.h * app/layer.h

View file

@ -71,29 +71,6 @@ static void help_debug_cmd_callback (GtkWidget *widget,
gpointer callback_data, gpointer callback_data,
guint callback_action); guint callback_action);
#ifdef ENABLE_NLS
/* from main.c */
extern gchar *plugin_domains[];
extern gint n_plugin_domains;
/* for i18n */
static gchar G_GNUC_UNUSED *dummy_entries[] =
{
/* <Image> */
N_("/Filters/Colors/Map"),
N_("/Filters/Render/Clouds"),
N_("/Filters/Render/Nature"),
N_("/Filters/Render/Pattern"),
N_("/Filters/Misc"),
/* Perl-Fu */
N_("/Xtns/Animation"),
N_("/Guides"),
};
#endif /* ENABLE_NLS */
static GSList *last_opened_raw_filenames = NULL; static GSList *last_opened_raw_filenames = NULL;
/***** <Toolbox> *****/ /***** <Toolbox> *****/
@ -942,10 +919,8 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
while (p) while (p)
{ {
g_string_assign (tearoff_path, entry->entry.path + factory_length); g_string_assign (tearoff_path, path + factory_length);
g_string_truncate (tearoff_path, g_string_truncate (tearoff_path, p - path - factory_length);
p - entry->entry.path + 1 - factory_length);
g_string_append (tearoff_path, "tearoff1");
if (! gtk_item_factory_get_widget (item_factory, if (! gtk_item_factory_get_widget (item_factory,
tearoff_path->str)) tearoff_path->str))
@ -956,7 +931,19 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
NULL, NULL,
NULL NULL
}; };
GimpItemFactoryEntry branch_entry =
{
{ NULL, NULL, NULL, 0, "<Branch>" },
NULL,
NULL
};
branch_entry.entry.path = tearoff_path->str;
gtk_object_set_data (GTK_OBJECT (item_factory), "complete", path);
menus_create_item (item_factory, &branch_entry, NULL, 2);
gtk_object_remove_data (GTK_OBJECT (item_factory), "complete");
g_string_append (tearoff_path, "/tearoff1");
tearoff_entry.entry.path = tearoff_path->str; tearoff_entry.entry.path = tearoff_path->str;
menus_create_item (item_factory, &tearoff_entry, NULL, 2); menus_create_item (item_factory, &tearoff_entry, NULL, 2);
} }
@ -1761,6 +1748,8 @@ menu_translate (const gchar *path,
gchar *factory; gchar *factory;
gchar *translation; gchar *translation;
gchar *domain = NULL; gchar *domain = NULL;
gchar *complete = NULL;
gchar *p, *t;
factory = (gchar *) data; factory = (gchar *) data;
@ -1779,20 +1768,59 @@ menu_translate (const gchar *path,
if (item_factory) if (item_factory)
domain = gtk_object_get_data (GTK_OBJECT (item_factory), "textdomain"); domain = gtk_object_get_data (GTK_OBJECT (item_factory), "textdomain");
if (domain) /* use the plugins textdomain */ if (domain) /* use the plugin textdomain */
{ {
g_free (menupath); g_free (menupath);
menupath = g_strconcat (factory, path, NULL); menupath = g_strconcat (factory, path, NULL);
translation = dgettext (domain, menupath); complete = gtk_object_get_data (GTK_OBJECT (item_factory), "complete");
if (complete)
{
/*
* This is a branch, use the complete path for translation,
* then strip off entries from the end until it matches.
*/
translation = g_strdup (dgettext (domain, complete));
complete = g_strdup (complete);
while (*complete && *translation && strcmp (complete, menupath))
{
p = strrchr (complete, '/');
t = strrchr (translation, '/');
if (p && t)
{
*p = '\0';
*t = '\0';
}
else
break;
}
g_free (complete);
}
else
{
translation = dgettext (domain, menupath);
}
/* /*
* Work around a bug in GTK+ prior to 1.2.7 (similar workaround below) * Work around a bug in GTK+ prior to 1.2.7 (similar workaround below)
*/ */
if (strncmp (factory, translation, strlen (factory)) == 0) if (strncmp (factory, translation, strlen (factory)) == 0)
retval = translation + strlen (factory); {
retval = translation + strlen (factory);
if (complete)
{
/* assign the result to menu_path, so it gets freed on next call */
g_free (menupath);
menupath = translation;
}
}
else else
g_warning ("bad translation for menupath: %s", menupath); {
g_warning ("bad translation for menupath: %s", menupath);
if (complete)
g_free (translation);
}
} }
else else
{ {

View file

@ -71,29 +71,6 @@ static void help_debug_cmd_callback (GtkWidget *widget,
gpointer callback_data, gpointer callback_data,
guint callback_action); guint callback_action);
#ifdef ENABLE_NLS
/* from main.c */
extern gchar *plugin_domains[];
extern gint n_plugin_domains;
/* for i18n */
static gchar G_GNUC_UNUSED *dummy_entries[] =
{
/* <Image> */
N_("/Filters/Colors/Map"),
N_("/Filters/Render/Clouds"),
N_("/Filters/Render/Nature"),
N_("/Filters/Render/Pattern"),
N_("/Filters/Misc"),
/* Perl-Fu */
N_("/Xtns/Animation"),
N_("/Guides"),
};
#endif /* ENABLE_NLS */
static GSList *last_opened_raw_filenames = NULL; static GSList *last_opened_raw_filenames = NULL;
/***** <Toolbox> *****/ /***** <Toolbox> *****/
@ -942,10 +919,8 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
while (p) while (p)
{ {
g_string_assign (tearoff_path, entry->entry.path + factory_length); g_string_assign (tearoff_path, path + factory_length);
g_string_truncate (tearoff_path, g_string_truncate (tearoff_path, p - path - factory_length);
p - entry->entry.path + 1 - factory_length);
g_string_append (tearoff_path, "tearoff1");
if (! gtk_item_factory_get_widget (item_factory, if (! gtk_item_factory_get_widget (item_factory,
tearoff_path->str)) tearoff_path->str))
@ -956,7 +931,19 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
NULL, NULL,
NULL NULL
}; };
GimpItemFactoryEntry branch_entry =
{
{ NULL, NULL, NULL, 0, "<Branch>" },
NULL,
NULL
};
branch_entry.entry.path = tearoff_path->str;
gtk_object_set_data (GTK_OBJECT (item_factory), "complete", path);
menus_create_item (item_factory, &branch_entry, NULL, 2);
gtk_object_remove_data (GTK_OBJECT (item_factory), "complete");
g_string_append (tearoff_path, "/tearoff1");
tearoff_entry.entry.path = tearoff_path->str; tearoff_entry.entry.path = tearoff_path->str;
menus_create_item (item_factory, &tearoff_entry, NULL, 2); menus_create_item (item_factory, &tearoff_entry, NULL, 2);
} }
@ -1761,6 +1748,8 @@ menu_translate (const gchar *path,
gchar *factory; gchar *factory;
gchar *translation; gchar *translation;
gchar *domain = NULL; gchar *domain = NULL;
gchar *complete = NULL;
gchar *p, *t;
factory = (gchar *) data; factory = (gchar *) data;
@ -1779,20 +1768,59 @@ menu_translate (const gchar *path,
if (item_factory) if (item_factory)
domain = gtk_object_get_data (GTK_OBJECT (item_factory), "textdomain"); domain = gtk_object_get_data (GTK_OBJECT (item_factory), "textdomain");
if (domain) /* use the plugins textdomain */ if (domain) /* use the plugin textdomain */
{ {
g_free (menupath); g_free (menupath);
menupath = g_strconcat (factory, path, NULL); menupath = g_strconcat (factory, path, NULL);
translation = dgettext (domain, menupath); complete = gtk_object_get_data (GTK_OBJECT (item_factory), "complete");
if (complete)
{
/*
* This is a branch, use the complete path for translation,
* then strip off entries from the end until it matches.
*/
translation = g_strdup (dgettext (domain, complete));
complete = g_strdup (complete);
while (*complete && *translation && strcmp (complete, menupath))
{
p = strrchr (complete, '/');
t = strrchr (translation, '/');
if (p && t)
{
*p = '\0';
*t = '\0';
}
else
break;
}
g_free (complete);
}
else
{
translation = dgettext (domain, menupath);
}
/* /*
* Work around a bug in GTK+ prior to 1.2.7 (similar workaround below) * Work around a bug in GTK+ prior to 1.2.7 (similar workaround below)
*/ */
if (strncmp (factory, translation, strlen (factory)) == 0) if (strncmp (factory, translation, strlen (factory)) == 0)
retval = translation + strlen (factory); {
retval = translation + strlen (factory);
if (complete)
{
/* assign the result to menu_path, so it gets freed on next call */
g_free (menupath);
menupath = translation;
}
}
else else
g_warning ("bad translation for menupath: %s", menupath); {
g_warning ("bad translation for menupath: %s", menupath);
if (complete)
g_free (translation);
}
} }
else else
{ {

View file

@ -71,29 +71,6 @@ static void help_debug_cmd_callback (GtkWidget *widget,
gpointer callback_data, gpointer callback_data,
guint callback_action); guint callback_action);
#ifdef ENABLE_NLS
/* from main.c */
extern gchar *plugin_domains[];
extern gint n_plugin_domains;
/* for i18n */
static gchar G_GNUC_UNUSED *dummy_entries[] =
{
/* <Image> */
N_("/Filters/Colors/Map"),
N_("/Filters/Render/Clouds"),
N_("/Filters/Render/Nature"),
N_("/Filters/Render/Pattern"),
N_("/Filters/Misc"),
/* Perl-Fu */
N_("/Xtns/Animation"),
N_("/Guides"),
};
#endif /* ENABLE_NLS */
static GSList *last_opened_raw_filenames = NULL; static GSList *last_opened_raw_filenames = NULL;
/***** <Toolbox> *****/ /***** <Toolbox> *****/
@ -942,10 +919,8 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
while (p) while (p)
{ {
g_string_assign (tearoff_path, entry->entry.path + factory_length); g_string_assign (tearoff_path, path + factory_length);
g_string_truncate (tearoff_path, g_string_truncate (tearoff_path, p - path - factory_length);
p - entry->entry.path + 1 - factory_length);
g_string_append (tearoff_path, "tearoff1");
if (! gtk_item_factory_get_widget (item_factory, if (! gtk_item_factory_get_widget (item_factory,
tearoff_path->str)) tearoff_path->str))
@ -956,7 +931,19 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
NULL, NULL,
NULL NULL
}; };
GimpItemFactoryEntry branch_entry =
{
{ NULL, NULL, NULL, 0, "<Branch>" },
NULL,
NULL
};
branch_entry.entry.path = tearoff_path->str;
gtk_object_set_data (GTK_OBJECT (item_factory), "complete", path);
menus_create_item (item_factory, &branch_entry, NULL, 2);
gtk_object_remove_data (GTK_OBJECT (item_factory), "complete");
g_string_append (tearoff_path, "/tearoff1");
tearoff_entry.entry.path = tearoff_path->str; tearoff_entry.entry.path = tearoff_path->str;
menus_create_item (item_factory, &tearoff_entry, NULL, 2); menus_create_item (item_factory, &tearoff_entry, NULL, 2);
} }
@ -1761,6 +1748,8 @@ menu_translate (const gchar *path,
gchar *factory; gchar *factory;
gchar *translation; gchar *translation;
gchar *domain = NULL; gchar *domain = NULL;
gchar *complete = NULL;
gchar *p, *t;
factory = (gchar *) data; factory = (gchar *) data;
@ -1779,20 +1768,59 @@ menu_translate (const gchar *path,
if (item_factory) if (item_factory)
domain = gtk_object_get_data (GTK_OBJECT (item_factory), "textdomain"); domain = gtk_object_get_data (GTK_OBJECT (item_factory), "textdomain");
if (domain) /* use the plugins textdomain */ if (domain) /* use the plugin textdomain */
{ {
g_free (menupath); g_free (menupath);
menupath = g_strconcat (factory, path, NULL); menupath = g_strconcat (factory, path, NULL);
translation = dgettext (domain, menupath); complete = gtk_object_get_data (GTK_OBJECT (item_factory), "complete");
if (complete)
{
/*
* This is a branch, use the complete path for translation,
* then strip off entries from the end until it matches.
*/
translation = g_strdup (dgettext (domain, complete));
complete = g_strdup (complete);
while (*complete && *translation && strcmp (complete, menupath))
{
p = strrchr (complete, '/');
t = strrchr (translation, '/');
if (p && t)
{
*p = '\0';
*t = '\0';
}
else
break;
}
g_free (complete);
}
else
{
translation = dgettext (domain, menupath);
}
/* /*
* Work around a bug in GTK+ prior to 1.2.7 (similar workaround below) * Work around a bug in GTK+ prior to 1.2.7 (similar workaround below)
*/ */
if (strncmp (factory, translation, strlen (factory)) == 0) if (strncmp (factory, translation, strlen (factory)) == 0)
retval = translation + strlen (factory); {
retval = translation + strlen (factory);
if (complete)
{
/* assign the result to menu_path, so it gets freed on next call */
g_free (menupath);
menupath = translation;
}
}
else else
g_warning ("bad translation for menupath: %s", menupath); {
g_warning ("bad translation for menupath: %s", menupath);
if (complete)
g_free (translation);
}
} }
else else
{ {

View file

@ -71,29 +71,6 @@ static void help_debug_cmd_callback (GtkWidget *widget,
gpointer callback_data, gpointer callback_data,
guint callback_action); guint callback_action);
#ifdef ENABLE_NLS
/* from main.c */
extern gchar *plugin_domains[];
extern gint n_plugin_domains;
/* for i18n */
static gchar G_GNUC_UNUSED *dummy_entries[] =
{
/* <Image> */
N_("/Filters/Colors/Map"),
N_("/Filters/Render/Clouds"),
N_("/Filters/Render/Nature"),
N_("/Filters/Render/Pattern"),
N_("/Filters/Misc"),
/* Perl-Fu */
N_("/Xtns/Animation"),
N_("/Guides"),
};
#endif /* ENABLE_NLS */
static GSList *last_opened_raw_filenames = NULL; static GSList *last_opened_raw_filenames = NULL;
/***** <Toolbox> *****/ /***** <Toolbox> *****/
@ -942,10 +919,8 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
while (p) while (p)
{ {
g_string_assign (tearoff_path, entry->entry.path + factory_length); g_string_assign (tearoff_path, path + factory_length);
g_string_truncate (tearoff_path, g_string_truncate (tearoff_path, p - path - factory_length);
p - entry->entry.path + 1 - factory_length);
g_string_append (tearoff_path, "tearoff1");
if (! gtk_item_factory_get_widget (item_factory, if (! gtk_item_factory_get_widget (item_factory,
tearoff_path->str)) tearoff_path->str))
@ -956,7 +931,19 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
NULL, NULL,
NULL NULL
}; };
GimpItemFactoryEntry branch_entry =
{
{ NULL, NULL, NULL, 0, "<Branch>" },
NULL,
NULL
};
branch_entry.entry.path = tearoff_path->str;
gtk_object_set_data (GTK_OBJECT (item_factory), "complete", path);
menus_create_item (item_factory, &branch_entry, NULL, 2);
gtk_object_remove_data (GTK_OBJECT (item_factory), "complete");
g_string_append (tearoff_path, "/tearoff1");
tearoff_entry.entry.path = tearoff_path->str; tearoff_entry.entry.path = tearoff_path->str;
menus_create_item (item_factory, &tearoff_entry, NULL, 2); menus_create_item (item_factory, &tearoff_entry, NULL, 2);
} }
@ -1761,6 +1748,8 @@ menu_translate (const gchar *path,
gchar *factory; gchar *factory;
gchar *translation; gchar *translation;
gchar *domain = NULL; gchar *domain = NULL;
gchar *complete = NULL;
gchar *p, *t;
factory = (gchar *) data; factory = (gchar *) data;
@ -1779,20 +1768,59 @@ menu_translate (const gchar *path,
if (item_factory) if (item_factory)
domain = gtk_object_get_data (GTK_OBJECT (item_factory), "textdomain"); domain = gtk_object_get_data (GTK_OBJECT (item_factory), "textdomain");
if (domain) /* use the plugins textdomain */ if (domain) /* use the plugin textdomain */
{ {
g_free (menupath); g_free (menupath);
menupath = g_strconcat (factory, path, NULL); menupath = g_strconcat (factory, path, NULL);
translation = dgettext (domain, menupath); complete = gtk_object_get_data (GTK_OBJECT (item_factory), "complete");
if (complete)
{
/*
* This is a branch, use the complete path for translation,
* then strip off entries from the end until it matches.
*/
translation = g_strdup (dgettext (domain, complete));
complete = g_strdup (complete);
while (*complete && *translation && strcmp (complete, menupath))
{
p = strrchr (complete, '/');
t = strrchr (translation, '/');
if (p && t)
{
*p = '\0';
*t = '\0';
}
else
break;
}
g_free (complete);
}
else
{
translation = dgettext (domain, menupath);
}
/* /*
* Work around a bug in GTK+ prior to 1.2.7 (similar workaround below) * Work around a bug in GTK+ prior to 1.2.7 (similar workaround below)
*/ */
if (strncmp (factory, translation, strlen (factory)) == 0) if (strncmp (factory, translation, strlen (factory)) == 0)
retval = translation + strlen (factory); {
retval = translation + strlen (factory);
if (complete)
{
/* assign the result to menu_path, so it gets freed on next call */
g_free (menupath);
menupath = translation;
}
}
else else
g_warning ("bad translation for menupath: %s", menupath); {
g_warning ("bad translation for menupath: %s", menupath);
if (complete)
g_free (translation);
}
} }
else else
{ {

View file

@ -75,14 +75,6 @@ static char *gap_main_version = "1.1.11b; 1999/11/20";
int gap_debug = 0; int gap_debug = 0;
/* for i18n */
static gchar G_GNUC_UNUSED *dummy_entries[] =
{
N_("<Image>/Video"),
N_("<Image>/Video/Encode")
};
static void query(void); static void query(void);
static void run(char *name, int nparam, GParam *param, static void run(char *name, int nparam, GParam *param,
int *nretvals, GParam **retvals); int *nretvals, GParam **retvals);

View file

@ -663,7 +663,7 @@ msgid "TYPE"
msgstr "TYP" msgstr "TYP"
msgid "<Image>/Guides/To Selection" msgid "<Image>/Guides/To Selection"
msgstr "<Image>/Guides/Als Auswahl" msgstr "<Image>/Hilfslinien/Als Auswahl"
msgid "<Image>/Filters/Noise/Feedback" msgid "<Image>/Filters/Noise/Feedback"
msgstr "<Image>/Filter/Noise/Feedback" msgstr "<Image>/Filter/Noise/Feedback"
@ -758,7 +758,7 @@ msgid "only blessed scalars accepted here"
msgstr "Objekt (nicht Referenz oder Skalar) benötigt" msgstr "Objekt (nicht Referenz oder Skalar) benötigt"
msgid "<Image>/Guides/Center Guide" msgid "<Image>/Guides/Center Guide"
msgstr "" msgstr "<Image>/Hilfslinien/Zentriert"
msgid "illegal parasite specification, arrayref expected" msgid "illegal parasite specification, arrayref expected"
msgstr "Illegaler Typ für 'parasite', erwarte Referenz auf Array" msgstr "Illegaler Typ für 'parasite', erwarte Referenz auf Array"

View file

@ -121,26 +121,6 @@ sfquit (void)
static void static void
query (void) query (void)
{ {
static gchar G_GNUC_UNUSED *dummy_entries[] = {
N_("<Toolbox>/Xtns/Script-Fu"),
N_("<Toolbox>/Xtns/Script-Fu/Logos"),
N_("<Toolbox>/Xtns/Script-Fu/Patterns"),
N_("<Toolbox>/Xtns/Script-Fu/Web Page Themes"),
N_("<Toolbox>/Xtns/Script-Fu/Utils"),
N_("<Toolbox>/Xtns/Script-Fu/Buttons"),
N_("<Toolbox>/Xtns/Script-Fu/Make Brush"),
N_("<Toolbox>/Xtns/Script-Fu/Misc"),
N_("<Toolbox>/Xtns/Script-Fu/Test"),
N_("<Image>/Script-Fu/Decor"),
N_("<Image>/Script-Fu/Utils"),
N_("<Image>/Script-Fu/Animators"),
N_("<Image>/Script-Fu/Stencil Ops"),
N_("<Image>/Script-Fu/Alchemy"),
N_("<Image>/Script-Fu/Selection"),
N_("<Image>/Script-Fu/Shadow"),
N_("<Image>/Script-Fu/Render"),
};
static GParamDef console_args[] = static GParamDef console_args[] =
{ {
{ PARAM_INT32, "run_mode", "Interactive, [non-interactive]" } { PARAM_INT32, "run_mode", "Interactive, [non-interactive]" }

View file

@ -112,7 +112,6 @@ query ()
static int nargs = sizeof (args) / sizeof (args[0]); static int nargs = sizeof (args) / sizeof (args[0]);
static GParamDef *return_vals = NULL; static GParamDef *return_vals = NULL;
static int nreturn_vals = 0; static int nreturn_vals = 0;
static gchar G_GNUC_UNUSED *dummy_entries = N_("<Toolbox>/Xtns/Web Browser");
INIT_I18N(); INIT_I18N();