Opened 6 years ago

Closed 6 years ago

#15219 closed defect (invalid)

wxLocale returns incorrect language in Windows 8

Reported by: raananc Owned by:
Priority: high Milestone: 2.9.5
Component: wxMSW Version:
Keywords: locale windows8 Cc:
Blocked By: Blocking:
Patch: no

Description

When 'internat' sample of 2.9 svn 74044 is executed on a Windows 8 system running in French (system setting says French), and when System default is selected, the returned language (in About) is English (en_GB) with WinLang = 9 & WinSublang = 2

When the code below is executed

wxLocale locale;
locale.Init();
int language = locale.GetSystemLanguage();
wxString languageString = locale.GetLanguageName(language);

it gives 56 (English) with 2.8.12, and 58 (English) with 2.9 svn 74044.

The expected value (the one returned in Vista and Windows 7) is French.

Applications translated correctly in Vista & Window 7 are not translated in Windows 8, making this a blocker.

Programs compiled with Visual C++ 2010 Express

Change History (11)

comment:1 Changed 6 years ago by neis

Might be a duplicate of #11594 ?

comment:2 Changed 6 years ago by raananc

On my Vista 32 bits and on my Windows 7 64 bits GetLanguage() and GetSystemLanguage() work correctly. On both systems the system language and the working language are the same (French).

On Windows 8 neither GetLanguage() nor GetSystemLanguage() work correctly, as described above.

comment:3 Changed 6 years ago by vadz

  • Component changed from base to wxMSW
  • Priority changed from critical to high

It would be great if you could please debug it a little, e.g. check what does the call to ::GetUserDefaultLCID() in wxLocale::GetSystemLanguage() return. It's true that #11594 should be fixed, but I don't understand why would this function stop working, it's mentioned nowhere in its documentation.

comment:4 Changed 6 years ago by vadz

  • Keywords windows8 added

comment:5 Changed 6 years ago by raananc

In Vista & in Windows 7 GetUserDefaultLCID() returns 1036.
In Windows 8 it returns 2037.

comment:6 Changed 6 years ago by dconnet

Out of curiosity, I ran the following on win8:

#define UNICODE
#define _UNICODE
#include <windows.h>
#include <iostream>

int main()
{

wchar_t buffer[1024];
LCID lcid = GetUserDefaultLCID();
int rc = GetUserDefaultLocaleName(buffer, _countof(buffer));

std::wcout << lcid << L" " << rc << L": " << buffer << "\n";

lcid = GetSystemDefaultLCID();
rc = GetSystemDefaultLocaleName(buffer, _countof(buffer));

std::wcout << lcid << L" " << rc << L": " << buffer << "\n";

return 0;

}
<<<

I then changed my (english installed) Win8 system to (system) French, user remained at english - results:
1033 6: en-US
1033 6: fr-FR

It appears the note that appears on the MSDN page for GetSystemDefaultLCID is true (http://msdn.microsoft.com/en-us/library/windows/desktop/dd318121%28v=vs.85%29.aspx).

"Note Any application that runs only on Windows Vista and later should use GetSystemDefaultLocaleName in preference to this function."

Well, for Win8, I guess "s/should/must/"...

comment:7 Changed 6 years ago by vadz

I have no idea what is 2037, it doesn't even appear in the list of all LCIDs. And I don't understand at all why does it return 2037 in wxWidgets but 1033 in your test program...

Does changing wxMSW code to use GetUserDefaultLocaleName() make it work as expected for you?

comment:8 Changed 6 years ago by raananc

I inserted in my app the following lines:

WCHAR localeName[256]={0};
int ret = GetUserDefaultLocaleName(localeName,256);

This gives ret = 6 and localName = en_GB;

No improvement.

comment:9 Changed 6 years ago by ericj

I made some tests on 3 different systems and i didn't see any problem.

There is only one significant difference, shown in the very last line: On an English Windows 8 with region settings to "German", everything returns "German" except GetUserDefaultUILanguage which returns "English". But this seems correct to me.

System 1:
=========
Windows 7/64 German

OS: Windows 7 (build 7600), 64-bit edition

Language: German
System locale name: German_Germany.1252
Canonical locale name: de_DE

GetUserDefaultLCID = 0x00000407
GetUserDefaultLocaleName: de-DE
GetUserDefaultUILanguage = 0x00000407

System 2:
=========

Windows 8/64 German

OS: Windows NT 6.2 (build 9200), 64-bit edition

Language: German
System locale name: German_Germany.1252
Canonical locale name: de_DE

GetUserDefaultLCID = 0x00000407
GetUserDefaultLocaleName: de-DE
GetUserDefaultUILanguage = 0x00000407

System 3:
=========

Windows 8/64 English, regional settings to "German"

OS: Windows NT 6.2 (build 9200), 64-bit edition

Language: German
System locale name: German_Germany.1252
Canonical locale name: de_DE

GetUserDefaultLCID = 0x00000407
GetUserDefaultLocaleName: de-DE
GetUserDefaultUILanguage = 0x00000409

comment:10 Changed 6 years ago by raananc

Looking at the Control panel/Region was a surprise: During the initial setup of my new Windows 8 amchine I selected French as the working language and, indeed, the system is using French and displays the correct time. However, the Region was set as England and the language was set as English!

Manually changing these values to France/French solved the problem: now both GetLanguage() and GetSystemLanguage() return Language_FRENCH, the expected value.

GetUserDefaultLCID() returns 1036, with lang = 12 & sublang = 1.

I am sorry for the trouble, wxLocale() works correctly on all my systems.

comment:11 Changed 6 years ago by vadz

  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.