Commit dcbf1345 authored by Yves Combe's avatar Yves Combe
Browse files

fix gcompris_set_locale to inform gettext locale has changed.

add gcompris_locales_list.
parent e4bb652a
2005-08-16 Yves Combe <yves@ycombe.net>
fix gcompris_set_locale to inform gettext locale has changed.
add gcompris_locales_list.
* src/boards/colors.c: (colors_config_start):
* src/gcompris/board_config.c: (gcompris_separator),
(gcompris_locales_list):
* src/gcompris/board_config.h:
* src/gcompris/gcompris.c: (gcompris_set_locale):
2005-08-15 Yves Combe <yves@ycombe.net>
add gcompris_separator() to make easily a GtkHSeparator in configuration.
......
......@@ -150,7 +150,7 @@ colors_config_start(GcomprisBoard *agcomprisBoard,
gcompris_separator();
GHashTable *table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
for (i =0; i< 10; i++)
for (i =0; i< 5; i++)
g_hash_table_insert ( table,
g_strdup_printf("key_%d", i),
g_strdup_printf("Radio Button %d", i)
......@@ -171,6 +171,29 @@ colors_config_start(GcomprisBoard *agcomprisBoard,
12);
g_hash_table_destroy( table);
GList *locales = gcompris_locales_list();
#define LOC "LC_MESSAGES"
gchar *actual_lang = gcompris_get_locale();
printf("%s was set to %s 1 of %d \n", LOC, actual_lang, g_list_length(locales));
while (locales){
printf("Locale %s exists for gcompris \n", locales->data);
gcompris_set_locale(locales->data);
printf("Cerveau %s\n", _("Brain"));
locales = locales->next;
}
gcompris_set_locale(actual_lang);
//segfault (list too long ? )
//gcompris_combo_box( "Gcompris locales", locales, "locale", 0);
}
/* ======================= */
......
/* gcompris - board_config.c
*
* Time-stamp: <2005/08/15 15:50:21 yves>
* Time-stamp: <2005/08/16 00:48:51 yves>
*
* Copyright (C) 2001 Pascal Georges
*
......@@ -471,6 +471,45 @@ GtkHSeparator *gcompris_separator()
}
/***********************************************/
/* L10n */
/***********************************************/
GList *gcompris_locales_list(){
gchar *textdomain;
GDir *textdomain_dir;
GError **error;
textdomain = bindtextdomain ("gcompris", NULL);
GList *locales = NULL;
textdomain_dir = g_dir_open (textdomain, 0, error);
const gchar *fname;
gchar *fname_abs;
gchar *catalog;
while (fname = g_dir_read_name(textdomain_dir)) {
fname_abs = g_strdup_printf("%s/%s",textdomain, fname);
if (!g_file_test(fname_abs, G_FILE_TEST_IS_DIR))
continue;
catalog = g_strdup_printf("%s/LC_MESSAGES/gcompris.mo", fname_abs);
if (g_file_test(catalog, G_FILE_TEST_EXISTS)){
locales = g_list_append( locales, g_strdup(fname));
}
g_free (fname_abs);
g_free(catalog);
}
g_free(textdomain);
g_dir_close (textdomain_dir);
return locales;
}
/* Local Variables: */
/* mode:c */
/* eval:(load-library "time-stamp") */
......
/* gcompris - board_config.h
*
* Time-stamp: <2005/08/15 14:42:59 yves>
* Time-stamp: <2005/08/15 17:27:18 yves>
*
* Copyright (C) 2001 Pascal Georges
*
......@@ -64,6 +64,8 @@ GtkSpinButton *gcompris_spin_int(const gchar *label,
GtkHSeparator *gcompris_separator();
GList *gcompris_locales_list();
#endif
/* Local Variables: */
......
/* gcompris - gcompris.c
*
* Time-stamp: <2005/08/03 00:52:23 bruno>
* Time-stamp: <2005/08/16 00:43:08 yves>
*
* Copyright (C) 2000-2003 Bruno Coudoin
*
......@@ -800,6 +800,9 @@ void gcompris_set_locale(gchar *locale)
setlocale(LC_ALL, locale);
#else
gcompris_locale = g_strdup(setlocale(LC_MESSAGES, locale));
if (!gcompris_locale)
gcompris_locale = g_strdup(locale);
setlocale("LC_ALL", "");
#endif
if(gcompris_locale!=NULL && strcmp(locale, gcompris_locale))
......@@ -821,6 +824,12 @@ void gcompris_set_locale(gchar *locale)
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
/* Make change known. */
{
extern int _nl_msg_cat_cntr;
++_nl_msg_cat_cntr;
}
}
void gcompris_log_handler (const gchar *log_domain,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment