From: Jactry Zeng jzeng@codeweavers.com
--- dlls/ntdll/locale.c | 9 ++++++++- dlls/user32/tests/resource.c | 25 +++++++++++++++++++++++++ dlls/user32/tests/resource.rc | 16 ++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c index 545cc628909..2c7503875a2 100644 --- a/dlls/ntdll/locale.c +++ b/dlls/ntdll/locale.c @@ -124,7 +124,14 @@ void locale_init(void) oem_cp = get_locale_data( locale_table, entry->idx )->idefaultcodepage;
NtQueryDefaultLocale( TRUE, &user_resource_lcid ); - user_resource_neutral_lcid = PRIMARYLANGID( user_resource_lcid ); + + if (user_resource_lcid == MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_HONGKONG ) + || user_resource_lcid == MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_MACAU )) + user_resource_neutral_lcid = MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL ); + else if (user_resource_lcid == MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_SINGAPORE )) + user_resource_neutral_lcid = MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED ); + else + user_resource_neutral_lcid = PRIMARYLANGID( user_resource_lcid ); if (user_resource_lcid == LOCALE_CUSTOM_UNSPECIFIED) { const NLS_LOCALE_LCNAME_INDEX *entry; diff --git a/dlls/user32/tests/resource.c b/dlls/user32/tests/resource.c index de4bb2c8a53..403927f0361 100644 --- a/dlls/user32/tests/resource.c +++ b/dlls/user32/tests/resource.c @@ -37,6 +37,7 @@ static void test_LoadStringW(void) WCHAR copiedstringw[128], returnedstringw[128], *resourcepointer = NULL; char copiedstring[128], returnedstring[128]; int length1, length2, retvalue, i; + LCID lang; static struct { int id; @@ -96,6 +97,30 @@ static void test_LoadStringW(void) retvalue = LoadStringW(hInst, 2, NULL, 128); ok(!retvalue, "LoadStringW returned a non-zero value when called with buffer = NULL, retvalue = %d\n", retvalue);
+ lang = GetUserDefaultLangID(); + memset(returnedstringw, 0xcc, sizeof(returnedstringw));; + if (lang == MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG) + || lang == MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_MACAU)) + { + length1 = LoadStringW(hInst, 1001, returnedstringw, sizeof(returnedstringw)); + ok(length1 == 20, "Got length %d.\n", length1); + ok(!wcscmp(returnedstringw, L"Chinese, Traditional"), "Got string %s.\n", debugstr_w(returnedstringw)); + + length1 = LoadStringW(hInst, 1002, returnedstringw, sizeof(returnedstringw)); + ok(!length1, "Got length %d.\n", length1); + ok(!*returnedstringw, "Got string %s.\n", debugstr_w(returnedstringw)); + } + else if (lang == MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SINGAPORE)) + { + length1 = LoadStringW(hInst, 1001, returnedstringw, sizeof(returnedstringw)); + ok(length1 == 19, "Got length %d.\n", length1); + ok(!wcscmp(returnedstringw, L"Chinese, Simplified"), "Got string %s.\n", debugstr_w(returnedstringw)); + + length1 = LoadStringW(hInst, 1002, returnedstringw, sizeof(returnedstringw)); + ok(!length1, "Got length %d.\n", length1); + ok(!*returnedstringw, "Got string %s.\n", debugstr_w(returnedstringw)); + } + /* Test builtin string table in user32. */ if ((PRIMARYLANGID(LANGIDFROMLCID(GetSystemDefaultLCID())) != LANG_ENGLISH) || (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) != LANG_ENGLISH)) diff --git a/dlls/user32/tests/resource.rc b/dlls/user32/tests/resource.rc index a957e50689d..f85e30dff73 100644 --- a/dlls/user32/tests/resource.rc +++ b/dlls/user32/tests/resource.rc @@ -286,3 +286,19 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,129,7,50,14 PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14 END + +STRINGTABLE LANGUAGE LANG_CHINESE, SUBLANG_NEUTRAL +{ + 1001 "Chinese" + 1002 "Chinese" +} + +STRINGTABLE LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED +{ + 1001 "Chinese, Simplified" +} + +STRINGTABLE LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL +{ + 1001 "Chinese, Traditional" +}