From: Jactry Zeng jzeng@codeweavers.com
This allows initializing locale from Mac locale identifiers like 'zh-Hans-US'. The current implementation recognizes it as 'zh-US' which isn't a valid locale identifier for Windows. This patch will try again with the 'lang-script' identifier after get_win_locale() fails with the 'lang-region' identifier. --- dlls/ntdll/unix/env.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 6b249917cfe..f691fa3eac2 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -796,6 +796,7 @@ static const NLS_LOCALE_DATA *get_win_locale( const NLS_LOCALE_HEADER *header, c */ static void init_locale(void) { + static char lang_script[LOCALE_NAME_MAX_LENGTH]; struct locale_nls_header *header; const NLS_LOCALE_HEADER *locale_table; const NLS_LOCALE_DATA *locale; @@ -833,6 +834,7 @@ static void init_locale(void) { CFStringRef lang = CFDictionaryGetValue( components, kCFLocaleLanguageCode ); CFStringRef country = CFDictionaryGetValue( components, kCFLocaleCountryCode ); + CFStringRef script = CFDictionaryGetValue( components, kCFLocaleScriptCode ); CFLocaleRef mac_user_locale = NULL; CFStringRef locale_string;
@@ -847,6 +849,14 @@ static void init_locale(void) locale_string = CFStringCreateCopy( NULL, lang ); CFStringGetCString( locale_string, user_locale, sizeof(user_locale), kCFStringEncodingUTF8 ); CFRelease( locale_string ); + + if (script) + { + locale_string = CFStringCreateWithFormat( NULL, NULL, CFSTR("%@-%@"), lang, script ); + CFStringGetCString( locale_string, lang_script, sizeof(lang_script), kCFStringEncodingUTF8 ); + CFRelease( locale_string ); + } + if (mac_user_locale) CFRelease( mac_user_locale ); CFRelease( components ); } @@ -862,6 +872,8 @@ static void init_locale(void) system_lcid = locale->idefaultlanguage; if ((locale = get_win_locale( locale_table, user_locale ))) user_lcid = locale->idefaultlanguage; + if (!user_lcid && (locale = get_win_locale( locale_table, lang_script ))) + user_lcid = locale->idefaultlanguage; free( header ); } if (!system_lcid) system_lcid = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );