Exemple #1
0
void CPBXClientApp::SetLanguage(CString lang) {		
#ifdef _UNICODE
    gettext_putenv(CStringA("LANG="+lang));
    bindtextdomain (GETTEXT_DOMAIN, CStringA(GetInstallDir()+"\\lang"));	
	bind_textdomain_codeset(GETTEXT_DOMAIN, "UCS-2LE");
	/*char *ch = ConvertFromUnicodeToMB(CString("LANG=")+lang);
	if (ch) {
		gettext_putenv(ch);
        free(ch);
	} else {
		return;
	}		
	ch = ConvertFromUnicodeToMB(GetInstallDir()+"\\lang");
	if (ch) {
		bindtextdomain (GETTEXT_DOMAIN, ch);
		free(ch);
	} else {
        return;
	}*/
#else
	gettext_putenv(CString("LANG=")+lang);
    bindtextdomain (GETTEXT_DOMAIN, GetInstallDir()+"\\lang");
#endif
	//setlocale(LC_ALL, "DECIMAL");
	textdomain (GETTEXT_DOMAIN);	
}
void
lincity_set_locale (void)
{
    char* locale = NULL;
    char* localem = NULL;
#if defined (WIN32)
#define MAX_LANG_BUF 1024
    char* language = NULL;
    char language_buf[MAX_LANG_BUF];
#endif

#if defined (ENABLE_NLS)
#if defined (WIN32)
    /* Some special stoopid way of setting locale for microsoft gettext */
    language = getenv ("LANGUAGE");
    if (language) {
	debug_printf ("Environment variable LANGUAGE is %s\n", language);
	snprintf (language_buf, MAX_LANG_BUF, "LANGUAGE=%s", language);
	gettext_putenv(language_buf);
    } else {
	debug_printf ("Environment variable LANGUAGE not set.\n");
    }
#else
    locale = setlocale (LC_ALL, "");
    debug_printf ("Setting entire locale to %s\n", locale);
    locale = setlocale (LC_MESSAGES, "");
    debug_printf ("Setting messages locale to %s\n", locale);
    localem = setlocale (LC_MESSAGES, NULL);
    debug_printf ("Query locale is %s\n", localem);
#endif
#endif /* ENABLE_NLS */
    return;
}
/**
 * Export the variable LC_XXXX to the system
 *
 * @param locale the locale (ex : fr_FR or en_US)
 */
BOOL exportLocaleToSystem(const wchar_t *locale)
{

    if (locale == NULL)
    {
#ifdef _MSC_VER
        fprintf(stderr, "Localization: Have not been able to find a suitable locale. Remains to default %s.\n", "LC_CTYPE");
#else
        fprintf(stderr, "Localization: Have not been able to find a suitable locale. Remains to default %ls.\n", EXPORTENVLOCALESTR);
#endif
        return FALSE;
    }

    /* It will put in the env something like LC_MESSAGES=fr_FR */
    if ( !setenvcW(EXPORTENVLOCALESTR, locale))
    {
#ifdef _MSC_VER
        fprintf(stderr, "Localization: Failed to declare the system variable %s.\n", "LC_CTYPE");
#else
        fprintf(stderr, "Localization: Failed to declare the system variable %d.\n", EXPORTENVLOCALE);
#endif
        return FALSE;
    }

#ifdef _MSC_VER
#ifdef USE_SAFE_GETTEXT_DLL
    {
        /* gettext is buggy on Windows */
        /* We need to set a external environment variable to scilab env. */
        char* pstr = NULL;
        wchar_t env[MAX_PATH];
        os_swprintf(env, MAX_PATH, L"%ls=%ls", EXPORTENVLOCALESTR, locale);
        pstr = wide_string_to_UTF8(env);
        gettext_putenv(pstr);
        FREE(pstr);
    }
#endif
#else
    /* Export LC_NUMERIC to the system to make sure that the rest of system
       is using the english notation (Java, Tcl ...) */
    setenvc("LC_NUMERIC", LCNUMERICVALUE);
#endif

    return TRUE;
}
Exemple #4
0
/* XXX WARNING!!! IN osx somehow the previous function call jumps in this one??? (ton, ppc) */
void BLF_lang_set(const char *str)
{
	char *locreturn;
	const char *short_locale;
	int ok = 1;
	const char *long_locale = locales[2 * U.language];

	if ((U.transopts&USER_DOTRANSLATE) == 0)
		return;

	if (str)
		short_locale = str;
	else
		short_locale = locales[ 2 * U.language + 1];

#if defined (_WIN32) && !defined(FREE_WINDOWS)
	if (short_locale) {
		char *envStr;

		if (U.language == 0)/* use system setting */
			envStr = BLI_sprintfN( "LANG=%s", getenv("LANG") );
		else
			envStr = BLI_sprintfN( "LANG=%s", short_locale );

		gettext_putenv(envStr);
		MEM_freeN(envStr);
	}

	locreturn = setlocale(LC_ALL, long_locale);

	if (locreturn == NULL) {
		if (G.debug & G_DEBUG)
			printf("Could not change locale to %s\n", long_locale);

		ok = 0;
	}
#else
	{
		static char default_lang[64] ="\0";
		static char default_language[64] ="\0";

		if (default_lang[0] == 0)
			get_language_variable("LANG", default_lang, sizeof(default_lang));

		if (default_language[0] == 0)
			get_language_variable("LANGUAGE", default_language, sizeof(default_language));

		if (short_locale[0]) {
			if (G.debug & G_DEBUG)
				printf("Setting LANG= and LANGUAGE to %s\n", short_locale);

			BLI_setenv("LANG", short_locale);
			BLI_setenv("LANGUAGE", short_locale);
		}
		else {
			if (G.debug & G_DEBUG)
				printf("Setting LANG=%s and LANGUAGE=%s\n", default_lang, default_language);

			BLI_setenv("LANG", default_lang);
			BLI_setenv("LANGUAGE", default_language);
		}

		locreturn = setlocale(LC_ALL, short_locale);

		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));

				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");

					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);

				locreturn = setlocale(LC_ALL, "");

				ok = 0;
			}

			if (short_locale_utf8)
				MEM_freeN(short_locale_utf8);
		}
	}
#endif

	if (ok) {
		/*printf("Change locale to %s\n", locreturn ); */
		BLI_strncpy(global_language, locreturn, sizeof(global_language));
	}

	setlocale(LC_NUMERIC, "C");

	textdomain(TEXT_DOMAIN_NAME);
	bindtextdomain(TEXT_DOMAIN_NAME, global_messagepath);
	bind_textdomain_codeset(TEXT_DOMAIN_NAME, global_encoding_name);
}
int LoadConfig() {
	HKEY myKey;
	DWORD type, size, tmp;
	PcsxConfig *Conf = &Config;
	int err;
#ifdef ENABLE_NLS
	char text[256];
#endif

	if (RegOpenKeyEx(HKEY_CURRENT_USER,cfgfile,0,KEY_ALL_ACCESS,&myKey)!=ERROR_SUCCESS) return -1;

	err = 1;
	QueryKey(256, "Bios", Conf->Bios);
	QueryKey(256, "Gpu",  Conf->Gpu);
	QueryKey(256, "Spu",  Conf->Spu);
	QueryKey(256, "Cdr",  Conf->Cdr);
	QueryKey(256, "Pad1", Conf->Pad1);
	QueryKey(256, "Pad2", Conf->Pad2);
#ifdef ENABLE_SIO1API
	QueryKey(256, "Sio1", Conf->Sio1);
#endif
	QueryKey(256, "Mcd1", Conf->Mcd1);
	QueryKey(256, "Mcd2", Conf->Mcd2);
	QueryKey(256, "PluginsDir", Conf->PluginsDir);
	QueryKey(256, "BiosDir",    Conf->BiosDir);
	err = 0;
	QueryKey(256, "Net",  Conf->Net);
	QueryKey(256, "Lang", Conf->Lang);

	QueryKeyV("Xa",       Conf->Xa);
	QueryKeyV("SioIrq",   Conf->SioIrq);
	QueryKeyV("Mdec",     Conf->Mdec);
	QueryKeyV("PsxAuto",  Conf->PsxAuto);
	QueryKeyV("Cdda",     Conf->Cdda);
	QueryKeyV("SlowBoot", Conf->SlowBoot);
	QueryKeyV("Debug",    Conf->Debug);
	QueryKeyV("PsxOut",   Conf->PsxOut);
	QueryKeyV("SpuIrq",   Conf->SpuIrq);
	QueryKeyV("RCntFix",  Conf->RCntFix);
	QueryKeyV("VSyncWA",  Conf->VSyncWA);
	QueryKeyV("Widescreen",  Conf->Widescreen);
	QueryKeyV("HideCursor",  Conf->HideCursor);
	QueryKeyV("SaveWindowPos",  Conf->SaveWindowPos);
	QueryKeyV("PerGameMcd", Conf->PerGameMcd);
	QueryKeyV("WindowPosX",  Conf->WindowPos[0]);
	QueryKeyV("WindowPosY",  Conf->WindowPos[1]);
	QueryKeyV("HackFix", Conf->HackFix);
	QueryKeyV("MemHack", Conf->MemHack);

	QueryKeyV("OverClock", Conf->OverClock);

	QueryKeyV("Cpu",      Conf->Cpu);
	QueryKeyV("PsxType",  Conf->PsxType);
	QueryKeyV("PsxClock", Conf->PsxClock);

	if (Config.Cpu == CPU_DYNAREC) {
		Config.Debug = 0; // don't enable debugger if using dynarec core
	}

	RegCloseKey(myKey);

#ifdef ENABLE_NLS
	sprintf(text, "LANGUAGE=%s", Conf->Lang);
	gettext_putenv(text);
#endif

	return 0;
}
Exemple #6
0
/* XXX WARNING!!! IN osx somehow the previous function call jumps in this one??? (ton, ppc) */
void BLF_lang_set(const char *str)
{
	char *locreturn;
	const char *short_locale;
	int ok= 1;
#if defined (_WIN32) && !defined(FREE_WINDOWS)
	const char *long_locale = locales[ 2 * U.language];
#endif

	if((U.transopts&USER_DOTRANSLATE)==0)
		return;

	if(str)
		short_locale = str;
	else
		short_locale = locales[ 2 * U.language + 1];

#if defined (_WIN32) && !defined(FREE_WINDOWS)
	if(short_locale) {
		char *envStr;

		if( U.language==0 )/* use system setting */
			envStr = BLI_sprintfN( "LANG=%s", getenv("LANG") );
		else
			envStr = BLI_sprintfN( "LANG=%s", short_locale );

		gettext_putenv(envStr);
		MEM_freeN(envStr);
	}

	locreturn= setlocale(LC_ALL, long_locale);

	if (locreturn == NULL) {
		printf("Could not change locale to %s\n", long_locale);
		ok= 0;
	}
#else
	{
		const char *locale;
		static char default_locale[64]="\0";

		if(default_locale[0]==0) {
			char *env_language= getenv("LANGUAGE");

			if(env_language) {
				char *s;

				/* store defaul locale */
				BLI_strncpy(default_locale, env_language, sizeof(default_locale));

				/* use first language as default */
				s= strchr(default_locale, ':');
				if(s) s[0]= 0;
			}
		}

		if(short_locale[0])
			locale= short_locale;
		else
			locale= default_locale;

		BLI_setenv("LANG", locale);
		BLI_setenv("LANGUAGE", locale);

		locreturn= setlocale(LC_ALL, locale);

		if (locreturn == NULL) {
			char *short_locale_utf8= BLI_sprintfN("%s.UTF-8", short_locale);

			locreturn= setlocale(LC_ALL, short_locale_utf8);

			if (locreturn == NULL) {
				printf("Could not change locale to %s nor %s\n", short_locale, short_locale_utf8);
				ok= 0;
			}

			MEM_freeN(short_locale_utf8);
		}
	}
#endif

	if(ok) {
		//printf("Change locale to %s\n", locreturn );
		BLI_strncpy(global_language, locreturn, sizeof(global_language));
	}

	setlocale(LC_NUMERIC, "C");

	textdomain(DOMAIN_NAME);
	bindtextdomain(DOMAIN_NAME, global_messagepath);
	bind_textdomain_codeset(DOMAIN_NAME, global_encoding_name);
}