mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-15 08:55:06 +00:00
kernel32: Keep the sublanguage specified by the script name when looking for the default.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
de7e687801
commit
c5a39bd98f
|
@ -362,31 +362,36 @@ static UINT find_charset( const WCHAR *name )
|
|||
return 0;
|
||||
}
|
||||
|
||||
static WORD get_default_sublang(LCID lang)
|
||||
static LANGID get_default_sublang( LANGID lang )
|
||||
{
|
||||
switch (PRIMARYLANGID(lang))
|
||||
switch (lang)
|
||||
{
|
||||
case LANG_SPANISH:
|
||||
return SUBLANG_SPANISH_MODERN;
|
||||
case LANG_CHINESE:
|
||||
return SUBLANG_CHINESE_SIMPLIFIED;
|
||||
default:
|
||||
return SUBLANG_DEFAULT;
|
||||
case MAKELANGID( LANG_SPANISH, SUBLANG_NEUTRAL ):
|
||||
return MAKELANGID( LANG_SPANISH, SUBLANG_SPANISH_MODERN );
|
||||
case MAKELANGID( LANG_CHINESE, SUBLANG_NEUTRAL ):
|
||||
return MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED );
|
||||
case MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_SINGAPORE ):
|
||||
return MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED );
|
||||
case MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL ):
|
||||
case MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_MACAU ):
|
||||
return MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_HONGKONG );
|
||||
}
|
||||
if (SUBLANGID( lang ) == SUBLANG_NEUTRAL) lang = MAKELANGID( PRIMARYLANGID(lang), SUBLANG_DEFAULT );
|
||||
return lang;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* find_locale_id_callback
|
||||
*/
|
||||
static BOOL CALLBACK find_locale_id_callback( HMODULE hModule, LPCWSTR type,
|
||||
LPCWSTR name, WORD LangID, LPARAM lParam )
|
||||
LPCWSTR name, LANGID lang, LPARAM lParam )
|
||||
{
|
||||
struct locale_name *data = (struct locale_name *)lParam;
|
||||
WCHAR buffer[128];
|
||||
int matches = 0;
|
||||
LCID lcid = MAKELCID( LangID, SORT_DEFAULT ); /* FIXME: handle sort order */
|
||||
LCID lcid = MAKELCID( lang, SORT_DEFAULT ); /* FIXME: handle sort order */
|
||||
|
||||
if (PRIMARYLANGID(LangID) == LANG_NEUTRAL) return TRUE; /* continue search */
|
||||
if (PRIMARYLANGID(lang) == LANG_NEUTRAL) return TRUE; /* continue search */
|
||||
|
||||
/* first check exact name */
|
||||
if (data->win_name[0] &&
|
||||
|
@ -435,7 +440,8 @@ static BOOL CALLBACK find_locale_id_callback( HMODULE hModule, LPCWSTR type,
|
|||
}
|
||||
else /* match default language */
|
||||
{
|
||||
if (SUBLANGID(LangID) == get_default_sublang( LangID )) matches++;
|
||||
LANGID def_lang = data->script ? lang : MAKELANGID( PRIMARYLANGID(lang), LANG_NEUTRAL );
|
||||
if (lang == get_default_sublang( def_lang )) matches++;
|
||||
}
|
||||
|
||||
if (data->codepage)
|
||||
|
@ -1720,8 +1726,7 @@ INT WINAPI GetLocaleInfoW( LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len )
|
|||
lang_id = LANGIDFROMLCID( lcid );
|
||||
|
||||
/* replace SUBLANG_NEUTRAL by SUBLANG_DEFAULT */
|
||||
if (SUBLANGID(lang_id) == SUBLANG_NEUTRAL)
|
||||
lang_id = MAKELANGID(PRIMARYLANGID(lang_id), get_default_sublang( lang_id ));
|
||||
if (SUBLANGID(lang_id) == SUBLANG_NEUTRAL) lang_id = get_default_sublang( lang_id );
|
||||
|
||||
if (!(hrsrc = FindResourceExW( kernel32_handle, (LPWSTR)RT_STRING,
|
||||
ULongToPtr((lctype >> 4) + 1), lang_id )))
|
||||
|
@ -2846,7 +2851,7 @@ LCID WINAPI ConvertDefaultLocale( LCID lcid )
|
|||
langid = LANGIDFROMLCID(lcid);
|
||||
if (SUBLANGID(langid) == SUBLANG_NEUTRAL)
|
||||
{
|
||||
langid = MAKELANGID(PRIMARYLANGID(langid), get_default_sublang( langid ));
|
||||
langid = get_default_sublang( langid );
|
||||
lcid = MAKELCID(langid, SORTIDFROMLCID(lcid));
|
||||
}
|
||||
}
|
||||
|
@ -4281,8 +4286,7 @@ static BOOL NLS_GetLanguageGroupName(LGRPID lgrpid, LPWSTR szName, ULONG nameSiz
|
|||
/* FIXME: Is it correct to use the system default langid? */
|
||||
langId = GetSystemDefaultLangID();
|
||||
|
||||
if (SUBLANGID(langId) == SUBLANG_NEUTRAL)
|
||||
langId = MAKELANGID(PRIMARYLANGID(langId), get_default_sublang( langId ));
|
||||
if (SUBLANGID(langId) == SUBLANG_NEUTRAL) langId = get_default_sublang( langId );
|
||||
|
||||
hResource = FindResourceExW( kernel32_handle, (LPWSTR)RT_STRING, szResourceName, langId );
|
||||
|
||||
|
|
|
@ -2781,36 +2781,35 @@ static void test_LocaleNameToLCID(void)
|
|||
|
||||
/* zh-Hant has LCID 0x7c04, but LocaleNameToLCID actually returns 0x0c04, which is the LCID of zh-HK */
|
||||
lcid = pLocaleNameToLCID(zhHantW, 0);
|
||||
todo_wine ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG), SORT_DEFAULT),
|
||||
ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG), SORT_DEFAULT),
|
||||
"%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhHantW), lcid);
|
||||
ret = pLCIDToLocaleName(lcid, buffer, sizeof(buffer)/sizeof(WCHAR), 0);
|
||||
ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhHantW), ret);
|
||||
todo_wine ok(!lstrcmpW(zhhkW, buffer), "%s: got wrong locale name %s\n",
|
||||
ok(!lstrcmpW(zhhkW, buffer), "%s: got wrong locale name %s\n",
|
||||
wine_dbgstr_w(zhHantW), wine_dbgstr_w(buffer));
|
||||
/* check that 0x7c04 also works and is mapped to zh-HK */
|
||||
ret = pLCIDToLocaleName(MAKELANGID(LANG_CHINESE_TRADITIONAL, SUBLANG_CHINESE_TRADITIONAL), buffer, sizeof(buffer)/sizeof(WCHAR), 0);
|
||||
todo_wine ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhHantW), ret);
|
||||
todo_wine ok(!lstrcmpW(zhhkW, buffer), "%s: got wrong locale name %s\n",
|
||||
ok(!lstrcmpW(zhhkW, buffer), "%s: got wrong locale name %s\n",
|
||||
wine_dbgstr_w(zhHantW), wine_dbgstr_w(buffer));
|
||||
|
||||
/* zh-hant */
|
||||
lcid = pLocaleNameToLCID(zhhantW, 0);
|
||||
todo_wine ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG), SORT_DEFAULT),
|
||||
"%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhhantW),
|
||||
MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG), SORT_DEFAULT));
|
||||
ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG), SORT_DEFAULT),
|
||||
"%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhhantW), lcid);
|
||||
ret = pLCIDToLocaleName(lcid, buffer, sizeof(buffer)/sizeof(WCHAR), 0);
|
||||
ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhhantW), ret);
|
||||
todo_wine ok(!lstrcmpW(zhhkW, buffer), "%s: got wrong locale name %s\n",
|
||||
ok(!lstrcmpW(zhhkW, buffer), "%s: got wrong locale name %s\n",
|
||||
wine_dbgstr_w(zhhantW), wine_dbgstr_w(buffer));
|
||||
|
||||
/* zh-Hans has LCID 0x0004, but LocaleNameToLCID actually returns 0x0804, which is the LCID of zh-CN */
|
||||
lcid = pLocaleNameToLCID(zhHansW, 0);
|
||||
/* check that LocaleNameToLCID actually returns 0x0804 */
|
||||
todo_wine ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT),
|
||||
ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT),
|
||||
"%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhHansW), lcid);
|
||||
ret = pLCIDToLocaleName(lcid, buffer, sizeof(buffer)/sizeof(WCHAR), 0);
|
||||
ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhHansW), ret);
|
||||
todo_wine ok(!lstrcmpW(zhcnW, buffer), "%s: got wrong locale name %s\n",
|
||||
ok(!lstrcmpW(zhcnW, buffer), "%s: got wrong locale name %s\n",
|
||||
wine_dbgstr_w(zhHansW), wine_dbgstr_w(buffer));
|
||||
/* check that 0x0004 also works and is mapped to zh-CN */
|
||||
ret = pLCIDToLocaleName(MAKELANGID(LANG_CHINESE, SUBLANG_NEUTRAL), buffer, sizeof(buffer)/sizeof(WCHAR), 0);
|
||||
|
@ -2820,12 +2819,11 @@ static void test_LocaleNameToLCID(void)
|
|||
|
||||
/* zh-hans */
|
||||
lcid = pLocaleNameToLCID(zhhansW, 0);
|
||||
todo_wine ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT),
|
||||
"%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhhansW),
|
||||
MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT));
|
||||
ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT),
|
||||
"%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhhansW), lcid);
|
||||
ret = pLCIDToLocaleName(lcid, buffer, sizeof(buffer)/sizeof(WCHAR), 0);
|
||||
ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhhansW), ret);
|
||||
todo_wine ok(!lstrcmpW(zhcnW, buffer), "%s: got wrong locale name %s\n",
|
||||
ok(!lstrcmpW(zhcnW, buffer), "%s: got wrong locale name %s\n",
|
||||
wine_dbgstr_w(zhhansW), wine_dbgstr_w(buffer));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue