localization patch for app-helper [Was: Re: help on child menus]
- From: Jaka Mocnik <jaka mocnik kiss uni-lj si>
- To: "John R. Sheets" <dusk ravendusk org>
- CC: gnome-devel-list gnome org, Miguel de Icaza <miguel gnu org>, mclos000 correo udg es
- Subject: localization patch for app-helper [Was: Re: help on child menus]
- Date: Fri, 09 Jul 1999 20:35:57 +0200
"John R. Sheets" wrote:
>
> On Fri, Jul 09, 1999 at 12:50:10AM +0000, mclos000@correu.udg.es wrote:
> > After compiling the program, I execute it and a window containing a mdi child
> > appers, also, the "File" menu and the "child" menu, but, the problem is that
> > the child is not listed in the child menu, and neither the menu associated to it.
> > Please, tell me if something is wrong!
>
> Hi Manuel,
>
> I'm having pretty much the same problem. I assume you're running
> with LANG=es, or something like that? I've found that the child
> menu items come up fine (in English) with LANG=C, but when someone
> runs it with in some other language, the child menu never gets
> populated. My theory (and I'm just now getting around to testing
> it) is that the menu declared in the GnomeUIInfo is slightly
> different from the menu in gnome_mdi_set_child_list_path().
thanks. you've opened my eyes wide, john. this is probably since I never
use localization but keep my LANG set to C.
the below appended patch for gnome-libs/libgnomeui/gnome-app-helper.c
(against the latest CVS) should take care of translating parts of the
menu path delimited by / on the fly and fix these kind of problems, but
I don't know if it is OK. all the programs seem to work fine with it
applied: I've tried ghex, gnome-hello-7-mdi, manuel's small proggy, etc.
I'd like Miguel or someone else with more in-depth knowledge of gettext
than me to inspect it and tell if it is really OK: especially with
regards to possible double translation (as most programs pass already
translated strings the menu insertion/removal routines, but I don't see
a problem with it) and memory leaks.
if it proves OK, I will commit it.
regards,
jaKa
--
w3: http://pluton.ijs.si/~jaka
email: jaka.mocnik@kiss.uni-lj.si
Index: gnome-app-helper.c
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-app-helper.c,v
retrieving revision 1.127
diff -u -r1.127 gnome-app-helper.c
--- gnome-app-helper.c 1999/05/26 07:20:30 1.127
+++ gnome-app-helper.c 1999/07/09 18:28:35
@@ -1917,6 +1917,7 @@
gchar *label = NULL;
GList *children, *hbox_children;
gchar *name_end;
+ gchar *part, *transl;
gint p;
int path_len;
int stripped_path_len;
@@ -1933,12 +1934,7 @@
else
path_len = name_end - path;
- stripped_path_len = path_len;
- for ( p = 0; p < path_len; p++ )
- if( path[p] == '_' )
- stripped_path_len--;
-
- if (path_len == 0){
+ if (path_len == 0) {
if (children && GTK_IS_TEAROFF_MENU_ITEM(children->data))
/* consider the position after the tear off item as the topmost one. */
@@ -1947,7 +1943,21 @@
*pos = 0;
return parent;
}
-
+
+ /* this ugly thing should fix the localization problems */
+ part = g_malloc(path_len + 1);
+ if(!part)
+ return NULL;
+ strncpy(part, path, path_len);
+ part[path_len] = '\0';
+ transl = L_(part);
+ path_len = strlen(transl);
+
+ stripped_path_len = path_len;
+ for ( p = 0; p < path_len; p++ )
+ if( transl[p] == '_' )
+ stripped_path_len--;
+
p = 0;
while (children){
@@ -1964,22 +1974,27 @@
label = GTK_LABEL (item->child)->label;
else
label = NULL; /* something that we just can't handle */
-
if (label && (stripped_path_len == strlen (label)) &&
- (g_strncmp_ignore_char (path, label, path_len, '_') == 0)){
+ (g_strncmp_ignore_char (transl, label, path_len, '_') == 0)){
if (name_end == NULL) {
*pos = p;
+ g_free(part);
return parent;
}
- else if (GTK_MENU_ITEM (item)->submenu)
+ else if (GTK_MENU_ITEM (item)->submenu) {
+ g_free(part);
return gnome_app_find_menu_pos
(GTK_MENU_ITEM (item)->submenu,
(gchar *)(name_end + 1), pos);
- else
+ }
+ else {
+ g_free(part);
return NULL;
+ }
}
}
+ g_free(part);
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]