kernel32: Consolidate some related code closer together.
This commit is contained in:
parent
b58cd975ba
commit
18d9632914
|
@ -2926,8 +2926,6 @@ void LOCALE_Init(void)
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
/* MacOS doesn't set the locale environment variables so we have to do it ourselves */
|
/* MacOS doesn't set the locale environment variables so we have to do it ourselves */
|
||||||
CFArrayRef preferred_locales, all_locales;
|
|
||||||
CFStringRef user_language_string_ref = NULL;
|
|
||||||
char user_locale[50];
|
char user_locale[50];
|
||||||
|
|
||||||
CFLocaleRef user_locale_ref = CFLocaleCopyCurrent();
|
CFLocaleRef user_locale_ref = CFLocaleCopyCurrent();
|
||||||
|
@ -2953,15 +2951,6 @@ void LOCALE_Init(void)
|
||||||
unix_cp = CP_UTF8; /* default to utf-8 even if we don't get a valid locale */
|
unix_cp = CP_UTF8; /* default to utf-8 even if we don't get a valid locale */
|
||||||
setenv( "LANG", user_locale, 0 );
|
setenv( "LANG", user_locale, 0 );
|
||||||
TRACE( "setting locale to '%s'\n", user_locale );
|
TRACE( "setting locale to '%s'\n", user_locale );
|
||||||
|
|
||||||
/* We still want to set the retrieve the preferred language as chosen in
|
|
||||||
System Preferences.app, because it can differ from CFLocaleCopyCurrent().
|
|
||||||
*/
|
|
||||||
all_locales = CFLocaleCopyAvailableLocaleIdentifiers();
|
|
||||||
preferred_locales = CFBundleCopyLocalizationsForPreferences( all_locales, NULL );
|
|
||||||
if (preferred_locales && CFArrayGetCount( preferred_locales ))
|
|
||||||
user_language_string_ref = CFArrayGetValueAtIndex( preferred_locales, 0 );
|
|
||||||
CFRelease( all_locales );
|
|
||||||
#endif /* __APPLE__ */
|
#endif /* __APPLE__ */
|
||||||
|
|
||||||
setlocale( LC_ALL, "" );
|
setlocale( LC_ALL, "" );
|
||||||
|
@ -2970,19 +2959,28 @@ void LOCALE_Init(void)
|
||||||
if (!lcid_LC_MESSAGES) lcid_LC_MESSAGES = lcid_LC_CTYPE;
|
if (!lcid_LC_MESSAGES) lcid_LC_MESSAGES = lcid_LC_CTYPE;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
/* Override lcid_LC_MESSAGES with user_language if LC_MESSAGES is set to default */
|
/* Override lcid_LC_MESSAGES with user's preferred language if LC_MESSAGES is set to default */
|
||||||
if (user_language_string_ref && !getenv("LC_ALL") && !getenv("LC_MESSAGES"))
|
if (!getenv("LC_ALL") && !getenv("LC_MESSAGES"))
|
||||||
{
|
{
|
||||||
struct locale_name locale_name;
|
/* Retrieve the preferred language as chosen in System Preferences. */
|
||||||
WCHAR buffer[128];
|
CFArrayRef all_locales = CFLocaleCopyAvailableLocaleIdentifiers();
|
||||||
CFStringGetCString( user_language_string_ref, user_locale, sizeof(user_locale), kCFStringEncodingUTF8 );
|
CFArrayRef preferred_locales = CFBundleCopyLocalizationsForPreferences( all_locales, NULL );
|
||||||
strcpynAtoW( buffer, user_locale, sizeof(buffer)/sizeof(WCHAR) );
|
CFStringRef user_language_string_ref;
|
||||||
parse_locale_name( buffer, &locale_name );
|
if (preferred_locales && CFArrayGetCount( preferred_locales ) &&
|
||||||
lcid_LC_MESSAGES = locale_name.lcid;
|
(user_language_string_ref = CFArrayGetValueAtIndex( preferred_locales, 0 )))
|
||||||
TRACE( "setting lcid_LC_MESSAGES to '%s'\n", user_locale );
|
{
|
||||||
|
struct locale_name locale_name;
|
||||||
|
WCHAR buffer[128];
|
||||||
|
CFStringGetCString( user_language_string_ref, user_locale, sizeof(user_locale), kCFStringEncodingUTF8 );
|
||||||
|
strcpynAtoW( buffer, user_locale, sizeof(buffer)/sizeof(WCHAR) );
|
||||||
|
parse_locale_name( buffer, &locale_name );
|
||||||
|
lcid_LC_MESSAGES = locale_name.lcid;
|
||||||
|
TRACE( "setting lcid_LC_MESSAGES to '%s'\n", user_locale );
|
||||||
|
}
|
||||||
|
CFRelease( all_locales );
|
||||||
|
if (preferred_locales)
|
||||||
|
CFRelease( preferred_locales );
|
||||||
}
|
}
|
||||||
if (preferred_locales)
|
|
||||||
CFRelease( preferred_locales );
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NtSetDefaultUILanguage( LANGIDFROMLCID(lcid_LC_MESSAGES) );
|
NtSetDefaultUILanguage( LANGIDFROMLCID(lcid_LC_MESSAGES) );
|
||||||
|
|
Loading…
Reference in New Issue