From 7c14bd2e8d775f4cfb5a04c70051e4a797da5d8b Mon Sep 17 00:00:00 2001 From: John Popplewell Date: Tue, 9 Aug 2005 14:23:07 +0000 Subject: [PATCH] Restores system locale detection for Windows. --lang=thai now works, still problem with e.g. French and German. --- src/tuxpaint.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 31f106c3c..ef9bd3730 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -701,9 +701,6 @@ static const char * lang_prefix; static void set_current_language(void) { char * loc; -#ifdef WIN32 - char str[128]; -#endif int lang, i, found; bindtextdomain("tuxpaint", LOCALEDIR); @@ -718,12 +715,29 @@ static void set_current_language(void) lang = LANG_EN; +#ifndef WIN32 loc = setlocale(LC_MESSAGES, NULL); if (loc != NULL) { if (strstr(loc, "LC_MESSAGES") != NULL) loc = getenv("LANG"); } +#else + loc = getenv("LANGUAGE"); + if (!loc) + { + loc = _nl_locale_name(LC_MESSAGES, ""); + if (loc) + { + char *s; + int len; + len = strlen("LANGUAGE=")+strlen(loc)+1; + s = malloc(len); + snprintf(s, len, "LANGUAGE=%s", loc); + putenv(s); + } + } +#endif debug(loc); @@ -749,7 +763,8 @@ static void set_current_language(void) need_right_to_left = search_int_array(lang,lang_use_right_to_left); #ifdef DEBUG - printf("DEBUG: Language is %s (%d)\n", lang_prefix, lang); + fprintf(stderr,"DEBUG: Language is %s (%d)\n", lang_prefix, lang); + fflush(stderr); #endif }