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
);
61 bind_textdomain_codeset("ROX-Filer", "UTF-8");
65 /* This is a hang-over from when we did translations ourselves.
66 * Maybe we can get this info from the gettext library?
68 lang
= getenv("LANG");
73 /* Extract the language code from the locale name.
74 * language[_territory][.codeset][@modifier]
77 end
= strchr(lang
, '.');
79 end
= strchr(lang
, '@');
81 current_lang
= g_strndup(lang
, end
- lang
);
83 current_lang
= g_strdup(lang
);
87 /* These two stolen from dia :-).
88 * Slight modification though: '>' means 'same as above' so that
89 * if a translation is missing it doesn't muck up the whole menu structure!
91 GtkItemFactoryEntry
*translate_entries(GtkItemFactoryEntry
*entries
, gint n
)
93 guchar
*first
= NULL
, *second
= NULL
; /* Previous menu, submenu */
95 GtkItemFactoryEntry
*ret
;
97 ret
= g_malloc(sizeof(GtkItemFactoryEntry
) * n
);
98 for (i
= 0; i
< n
; i
++)
100 const gchar
*from
= entries
[i
].path
;
101 gchar
*trans
, *slash
;
115 from
= _(from
+ indent
);
120 trans
= g_strdup_printf("/%s", from
);
121 else if (indent
== 1)
122 trans
= g_strdup_printf("/%s/%s", first
, from
);
124 trans
= g_strdup_printf("/%s/%s/%s",
125 first
, second
, from
);
130 null_g_free(&second
);
133 slash
= strchr(trans
, '/');
136 first
= g_strndup(trans
, slash
- trans
);
139 slash
= strchr(trans
, '/');
141 second
= g_strndup(trans
, slash
- trans
);
143 second
= g_strdup(trans
);
146 first
= g_strdup(trans
);
148 /* accelerator and item_type are not duped, only referenced */
149 ret
[i
].accelerator
= entries
[i
].accelerator
;
150 ret
[i
].callback
= entries
[i
].callback
;
151 ret
[i
].callback_action
= entries
[i
].callback_action
;
152 ret
[i
].item_type
= entries
[i
].item_type
;
153 ret
[i
].extra_data
= entries
[i
].extra_data
;
162 void free_translated_entries(GtkItemFactoryEntry
*entries
, gint n
)
167 g_free(entries
[i
].path
);