kernel32: Allow the prefered language to be different from the prefered locale on Mac OS X. [take3]

Ken Thomases ken at codeweavers.com
Wed Dec 13 09:46:29 CST 2006


Wait, wait...

On Dec 12, 2006, at 6:55 AM, Pierre d'Herbemont wrote:

> This time with Alexandre suggestion to use directly parse_locale_name.
>
> We still leave the possibility not to use the System preferences  
> language if LC_MESSAGES env variable LC_MESSAGES was set to a value  
> different than the default ("C").
>
> Pierre.
> ---
>  dlls/kernel32/locale.c |   37 ++++++++++++++++++++++++++++++++++++-
>  1 files changed, 36 insertions(+), 1 deletions(-)
> diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
> index 8792623..c70e08c 100644
> --- a/dlls/kernel32/locale.c
> +++ b/dlls/kernel32/locale.c
> @@ -2832,11 +2839,39 @@ void LOCALE_Init(void)
>      unix_cp = CP_UTF8;  /* default to utf-8 even if we don't get a  
> valid locale */
>      setenv( "LANG", user_locale, 0 );
>      TRACE( "setting locale to '%s'\n", user_locale );
> -#endif
> +
> +    /* We still want to set the retrieve the prefered language as  
> choosen in
> +       System Preferences.app, because it can differ from  
> CFLocaleCopyCurrent().
> +    */
> +    all_locales = CFLocaleCopyAvailableLocaleIdentifiers();
> +    preferred_locales = CFBundleCopyLocalizationsForPreferences 
> ( all_locales, NULL );

I thought I explained that exactly the above combination of calls  
produces unusable results.  For example, for me it produces "en_ZW"  
-- English (Zimbabwe).  In System Preferences, I have set  
"English" (no country) as my preferred language and U.S. for other  
locale settings.

In other words, it is picking a random country.

> +    if (preferred_locales)
> +    {
> +        if (CFArrayGetCount( preferred_locales ))
> +            user_language_string_ref = CFArrayGetValueAtIndex 
> ( preferred_locales, 0 );
> +        CFRelease( preferred_locales );
> +    }
> +    CFRelease( all_locales );
> +#endif /* __APPLE__ */
> +
>      setlocale( LC_ALL, "" );
>
>      unix_cp = setup_unix_locales();
>      if (!lcid_LC_MESSAGES) lcid_LC_MESSAGES = lcid_LC_CTYPE;
> +#ifdef __APPLE__
> +    /* Override lcid_LC_MESSAGES with user_language if LC_MESSAGES  
> is set to default */
> +    if (lcid_LC_MESSAGES == lcid_LC_CTYPE &&  
> user_language_string_ref)
> +    {
> +        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 );
> +    }
> +#endif
> +
>      NtSetDefaultUILanguage( LANGIDFROMLCID(lcid_LC_MESSAGES) );
>      NtSetDefaultLocale( TRUE, lcid_LC_MESSAGES );
>      NtSetDefaultLocale( FALSE, lcid_LC_CTYPE );
>
>




More information about the wine-patches mailing list