use var lang instead of alias LANG, and some cleanup in language detection
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6774 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+11
-5
@@ -3,6 +3,8 @@
|
||||
#include "cube.h"
|
||||
#include <locale.h>
|
||||
|
||||
SVARP(lang, "");
|
||||
|
||||
i18nmanager::i18nmanager(const char *domain, const char *basepath) : domain(domain), basepath(basepath)
|
||||
{
|
||||
locale = setlocale(LC_ALL, ""); // use current default locale
|
||||
@@ -10,14 +12,18 @@ i18nmanager::i18nmanager(const char *domain, const char *basepath) : domain(doma
|
||||
textdomain(domain);
|
||||
bind_textdomain_codeset(domain, "UTF-8"); // we use the utf-8 charset only
|
||||
|
||||
char lang[3];
|
||||
|
||||
char localelang[3];
|
||||
if(!lang[0])
|
||||
{
|
||||
#ifdef WIN32
|
||||
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, lang, 3);
|
||||
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, localelang, 3);
|
||||
#else
|
||||
copystring(lang, locale, 3);
|
||||
copystring(localelang, locale, 3);
|
||||
#endif
|
||||
filterlang(lang, lang);
|
||||
alias("LANG", lang);
|
||||
filterlang(localelang, localelang);
|
||||
copystring(lang, localelang, 3);
|
||||
}
|
||||
printf("current locale: %s (%s)\n", locale, lang);
|
||||
|
||||
setlocale(LC_NUMERIC, "C"); // make sure numeric is consistent (very important for float usage in scripts)
|
||||
|
||||
Reference in New Issue
Block a user