I have XP with the French language pack installed (and XP SP3).
When French is selected as the user language GetUserDefaultLCID() returns 0x0809 (1252) (UK English) and
GetSystemDefaultLCID() returns 0x0409 (1033) (US English). (No problem as I only use the lower 8 bits of the LCID, i.e.
0x09 for English or 0xC0 for French).
All the system messages are in French.
How do I get the system to return the French LCID 0x040C (1252) when the user locale is French?
Is there some other way to detect the user's selected locale other than GetUserDefaultLCID().
Thanks,
Jan
What do you mean by "French is selected as the user language" ?
The language of the UI? (in which the interface is translated)
That is not the user locale, that is the UI locale.
Short guide to lingo:
- User locale = used for locale sensitive operations
(time/date/number/currency formatting, sorting, etc.)
=> GetUserDefaultLCID
- System locale = used by non-Unicode applications
Determines the ANSI and OEM code pages
=> GetSystemDefaultLCID
- UI locale = determines the localization of the interface
=> GetUserDefaultUILanguage => returns a LANGID
- Default system UI language = the language of the UI in which
the OS was initially installed
=> GetSystemDefaultUILanguage
--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Thanks for your reply.
My executable is a Windows Installer (MSI) "Custom Action".
From my research it appears that with a custom action spawned by MSI, GetUserDefaultLCID() and
GetUserDefaultUILanguage() return the country code of the .msi file not the users locale or language.
Running the executable as opposed to spawning from MSI results in the correct country code being returned.
Regards,
Jan
Even if the .msi file localization is "French" and the user Language Pack selected is also "Francais (French)", an MSI
Custom Action calling GetUserDefaultLCID() and GetUserDefaultUILanguage() return 0x0809 and 0x0409 respectively.
Jan
It is very likely that the msi, doing install stuff, runs in the context
of the Administrator, not the current user. So any GetUser* will get Admin
settings, not the current user.
If you can span something from the msi and report the user and group, might
help find a workaround.
Something that might work is to change from Regional Settings, Advanced tab.
Check the "Apply all settings to the current account and to the default user
profile"
http://library.ust.hk/images/advanced-tab.jpg
Or you might login as Administrator and change the settings.
Not sure which method will ork, or if any of them will work.
The best thing is to span an exe, report user/group, and will go from there.
Thanks for your suggestions. I will look into them when I get a moment. Meanwhile I have handled the problem by passing
the language code of the .msi file to the Custom Action on the command line. As MSI expects a different .msi file for
each language this will sort the problem in the short term.
Regards,
Jan
P.S. As this forum is officially closed, where should I post language questions in future?
Franckly, I don't know :-(
There is no new forum dedicated to internationalization.
You might have a decent chance at stackoverflow.com