4 * ROX-Filer, filer for the ROX desktop project
5 * Copyright (C) 2000, Thomas Leonard, <tal197@ecs.soton.ac.uk>.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 * Place, Suite 330, Boston, MA 02111-1307 USA
40 #include "gui_support.h"
44 /****************************************************************
45 * EXTERNAL INTERFACE *
46 ****************************************************************/
49 /* Set things up for internationalisation */
54 lang
= getenv("LANG");
57 setlocale(LC_ALL
, "");
65 path
= g_strdup_printf("%s/Messages/%s.gmo", app_dir
, lang
);
66 if (stat(path
, &info
) == 0)
67 rox_add_translations(path
);
73 /****************************************************************
74 * INTERNAL FUNCTIONS *
75 ****************************************************************/
78 /* These two stolen from dia :-).
79 * Slight modification though: '/%s/' means 'same as above' so that
80 * if a translation is missing it doesn't muck up the whole menu structure!
82 GtkItemFactoryEntry
*translate_entries(GtkItemFactoryEntry
*entries
, gint n
)
84 guchar
*first
= NULL
, *second
= NULL
; /* Previous menu, submenu */
86 GtkItemFactoryEntry
*ret
;
88 ret
= g_malloc(sizeof(GtkItemFactoryEntry
) * n
);
89 for (i
= 0; i
< n
; i
++)
91 guchar
*from
= entries
[i
].path
;
92 guchar
*trans
, *slash
;
106 from
= _(from
+ indent
);
111 trans
= g_strdup_printf("/%s", from
);
112 else if (indent
== 1)
113 trans
= g_strdup_printf("/%s/%s", first
, from
);
115 trans
= g_strdup_printf("/%s/%s/%s",
116 first
, second
, from
);
125 slash
= strchr(trans
, '/');
128 first
= g_strndup(trans
, slash
- trans
);
131 slash
= strchr(trans
, '/');
133 second
= g_strndup(trans
, slash
- trans
);
135 second
= g_strdup(trans
);
138 first
= g_strdup(trans
);
140 /* accelerator and item_type are not duped, only referenced */
141 ret
[i
].accelerator
= entries
[i
].accelerator
;
142 ret
[i
].callback
= entries
[i
].callback
;
143 ret
[i
].callback_action
= entries
[i
].callback_action
;
144 ret
[i
].item_type
= entries
[i
].item_type
;
153 void free_translated_entries(GtkItemFactoryEntry
*entries
, gint n
)
158 g_free(entries
[i
].path
);