2 * ROX-Filer, filer for the ROX desktop project
3 * Copyright (C) 2006, Thomas Leonard and others (see changelog for details).
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
36 #include "gui_support.h"
39 #define MESSAGE _("Note that you must save your choices " \
40 "and restart the filer for the new language " \
41 "setting to take full effect.")
43 /* Two/five-char country_territory code, or NULL */
44 char *current_lang
= NULL
;
46 /****************************************************************
47 * EXTERNAL INTERFACE *
48 ****************************************************************/
51 /* Set things up for internationalisation */
59 gchar
*path
= g_strdup_printf("%s/Messages", app_dir
);
60 bindtextdomain("ROX-Filer", path
);
64 /* This is a hang-over from when we did translations ourselves.
65 * Maybe we can get this info from the gettext library?
67 lang
= getenv("LANG");
72 /* Extract the language code from the locale name.
73 * language[_territory][.codeset][@modifier]
76 end
= strchr(lang
, '.');
78 end
= strchr(lang
, '@');
80 current_lang
= g_strndup(lang
, end
- lang
);
82 current_lang
= g_strdup(lang
);
86 /* These two stolen from dia :-).
87 * Slight modification though: '>' means 'same as above' so that
88 * if a translation is missing it doesn't muck up the whole menu structure!
90 GtkItemFactoryEntry
*translate_entries(GtkItemFactoryEntry
*entries
, gint n
)
92 guchar
*first
= NULL
, *second
= NULL
; /* Previous menu, submenu */
94 GtkItemFactoryEntry
*ret
;
96 ret
= g_malloc(sizeof(GtkItemFactoryEntry
) * n
);
97 for (i
= 0; i
< n
; i
++)
99 const gchar
*from
= entries
[i
].path
;
100 gchar
*trans
, *slash
;
114 from
= _(from
+ indent
);
119 trans
= g_strdup_printf("/%s", from
);
120 else if (indent
== 1)
121 trans
= g_strdup_printf("/%s/%s", first
, from
);
123 trans
= g_strdup_printf("/%s/%s/%s",
124 first
, second
, from
);
129 null_g_free(&second
);
132 slash
= strchr(trans
, '/');
135 first
= g_strndup(trans
, slash
- trans
);
138 slash
= strchr(trans
, '/');
140 second
= g_strndup(trans
, slash
- trans
);
142 second
= g_strdup(trans
);
145 first
= g_strdup(trans
);
147 /* accelerator and item_type are not duped, only referenced */
148 ret
[i
].accelerator
= entries
[i
].accelerator
;
149 ret
[i
].callback
= entries
[i
].callback
;
150 ret
[i
].callback_action
= entries
[i
].callback_action
;
151 ret
[i
].item_type
= entries
[i
].item_type
;
152 ret
[i
].extra_data
= entries
[i
].extra_data
;
161 void free_translated_entries(GtkItemFactoryEntry
*entries
, gint n
)
166 g_free(entries
[i
].path
);