kernel32: Mac: If language is less specific variant of locale, keep locale.

For a Mac user in Australia, for example, the out-of-the-box configuration is
that the preferred language is generic English ("en").  Their formats locale
should be Australia ("en_AU").  Detect that case and don't override
LC_MESSAGES.
This commit is contained in:
Ken Thomases 2010-02-19 09:44:26 -06:00 committed by Alexandre Julliard
parent d013991d55
commit 8c2b290d11
1 changed files with 7 additions and 3 deletions

View File

@ -2945,8 +2945,6 @@ void LOCALE_Init(void)
}
CFStringGetCString( user_locale_string_ref, user_locale, sizeof(user_locale), kCFStringEncodingUTF8 );
CFRelease( user_locale_ref );
CFRelease( user_locale_string_ref );
unix_cp = CP_UTF8; /* default to utf-8 even if we don't get a valid locale */
setenv( "LANG", user_locale, 0 );
@ -2963,11 +2961,14 @@ void LOCALE_Init(void)
if (!getenv("LC_ALL") && !getenv("LC_MESSAGES"))
{
/* Retrieve the preferred language as chosen in System Preferences. */
/* If language is a less specific variant of locale (e.g. 'en' vs. 'en_US'),
leave things be. */
CFArrayRef all_locales = CFLocaleCopyAvailableLocaleIdentifiers();
CFArrayRef preferred_locales = CFBundleCopyLocalizationsForPreferences( all_locales, NULL );
CFStringRef user_language_string_ref;
if (preferred_locales && CFArrayGetCount( preferred_locales ) &&
(user_language_string_ref = CFArrayGetValueAtIndex( preferred_locales, 0 )))
(user_language_string_ref = CFArrayGetValueAtIndex( preferred_locales, 0 )) &&
!CFEqual(user_language_string_ref, user_locale_lang_ref))
{
struct locale_name locale_name;
WCHAR buffer[128];
@ -2981,6 +2982,9 @@ void LOCALE_Init(void)
if (preferred_locales)
CFRelease( preferred_locales );
}
CFRelease( user_locale_ref );
CFRelease( user_locale_string_ref );
#endif
NtSetDefaultUILanguage( LANGIDFROMLCID(lcid_LC_MESSAGES) );