Terry Chen
Terry Chen

Reputation: 469

GetUserDefaultUILanguage API returns incorrect language on Win8.1 for French Canada

I set the language of my windows 8.1 system to French Canada(Fr-ca), and use GetUserDefaultUILanguage API to get the user default language, but it returns value 1036(Fr-fr) which is incorrect, it should be 3084(Fr-ca). And it returns a correct value(3084) on windows 10. Do you know how to get the correct value on Window 8.1 for Fr-ca?

Upvotes: 2

Views: 1833

Answers (1)

Maestro
Maestro

Reputation: 428

I experimented the same results from the same systems you mention:

Windows 7 returns "fr-FR" (the OS only allows to select "french" anyway!) Windows 8.1 returns "fr-FR" even though "français (Canada)" is selected in the languages configuration. Windows 10 returns "fr-CA", having enabled "français (Canada)" for UI display.

The MSDN API documentation mentions this for Remarks:

This function returns only a language identifier. An application can retrieve the language name using the GetUserPreferredUILanguages function.

It becomes more obvious that the results you get are likely correct when using this GetUserPreferredUILanguages method:

In the case of Windows 7, the list returns:

fr-FR

In the case of Windows 8.1, the list returns:

fr-FR, en-US

In the case of Windows 10, the list returns:

fr-CA, fr-FR, en-US

So, I interpret the API returns the system priority list for UI resources. In the case of Windows 8.1, there is likely no specialization of the UI resources for french Canada. In all cases, it falls back on French french... and in last resort, it takes the "install language" from the installation disk (in my case, en-US) if the resource would not have translation.

Upvotes: 2

Related Questions