diff options
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r-- | source/blender/blenfont/intern/blf_lang.c | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index ff574a71549..284983b346a 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -214,11 +214,33 @@ void BLF_lang_set(const char *str) get_language_variable("LANGUAGE", default_language, sizeof(default_language)); if (short_locale[0]) { + char *short_locale_utf8 = BLI_sprintfN("%s.UTF-8", short_locale); + if (G.debug & G_DEBUG) - printf("Setting LANG= and LANGUAGE to %s\n", short_locale); + printf("Setting LANG and LANGUAGE to %s\n", short_locale_utf8); + + locreturn = setlocale(LC_ALL, short_locale_utf8); + + if (locreturn != NULL) { + BLI_setenv("LANG", short_locale_utf8); + BLI_setenv("LANGUAGE", short_locale_utf8); + } + else { + if (G.debug & G_DEBUG) + printf("Setting LANG and LANGUAGE to %s\n", short_locale); + + locreturn = setlocale(LC_ALL, short_locale); - BLI_setenv("LANG", short_locale); - BLI_setenv("LANGUAGE", short_locale); + if (locreturn != NULL) { + BLI_setenv("LANG", short_locale); + BLI_setenv("LANGUAGE", short_locale); + } + } + + if (G.debug & G_DEBUG && locreturn == NULL) + printf("Could not change locale to %s nor %s\n", short_locale, short_locale_utf8); + + MEM_freeN(short_locale_utf8); } else { if (G.debug & G_DEBUG) @@ -226,43 +248,27 @@ void BLF_lang_set(const char *str) BLI_setenv("LANG", default_lang); BLI_setenv("LANGUAGE", default_language); - } + locreturn = setlocale(LC_ALL, ""); - locreturn = setlocale(LC_ALL, short_locale); + if (G.debug & G_DEBUG && locreturn == NULL) + printf("Could not reset locale\n"); + } if (locreturn == NULL) { - char *short_locale_utf8 = NULL; - - if (short_locale[0]) { - short_locale_utf8 = BLI_sprintfN("%s.UTF-8", short_locale); - locreturn = setlocale(LC_ALL, short_locale_utf8); - } - - if (locreturn == NULL) { - char language[65]; - - get_language(long_locale, default_lang, language, sizeof(language)); + char language[65]; - if (G.debug & G_DEBUG) { - if (short_locale[0]) - printf("Could not change locale to %s nor %s\n", short_locale, short_locale_utf8); - else - printf("Could not reset locale\n"); + get_language(long_locale, default_lang, language, sizeof(language)); - printf("Fallback to LANG=%s and LANGUAGE=%s\n", default_lang, language); - } - - /* Fallback to default settings. */ - BLI_setenv("LANG", default_lang); - BLI_setenv("LANGUAGE", language); + if (G.debug & G_DEBUG) + printf("Fallback to LANG=%s and LANGUAGE=%s\n", default_lang, language); - locreturn = setlocale(LC_ALL, ""); + /* Fallback to default settings. */ + BLI_setenv("LANG", default_lang); + BLI_setenv("LANGUAGE", language); - ok = 0; - } + locreturn = setlocale(LC_ALL, ""); - if (short_locale_utf8) - MEM_freeN(short_locale_utf8); + ok = 0; } } #endif |