by Michael S. Kaplan, published on 2006/05/13 13:15 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2006/05/13/596971.aspx
The SZ (a.k.a. Steffen) asked in the suggestion box:
What is the prefered way to select the "most usefull" language in a multi language app?
If I'm using "LoadString" I'm getting the os language
If I'm using "GetUserDefaultUILanguage" I'm getting the os language if no mui pack is installed.
I know there are are a lot of posts about the trillions of different language api's. I know windows doesn't have a "I wanna that the apps are talking 'german'" setting. But a german user on a english os will set something or all possible settings in the control panel to something german.
Currently I'm using GetUserDefaultLangID.
Actually, the LoadString function is a simple wrapper around FindResource, which uses the user UI language provided by GetUserDefaultUILanguage. Before the Multilingual User Interface existed, this was always the OS install language, but now it is completely configurable to whatever language th operating system is set to.
While it makes a good default (there is an obvious good faith basis that a developer can assume that a user knows the language into which the OS is translated, at least well enough to navigate to an installed application!), it is always possible that an application might be translated into more languages than are actually available in the UI language list.
In such cases, an application might still wish to use the UI language provided by GetUserDefaultUILanguage as a starting point, it may make sense to provide a custom user interface to allow language selection that diverges from the operating system list....
Of course, going down the FindResourceEx/LoadResource/LockResource route starts off easily enough but gets more complicated after that, which is one of the reasons that LoadString is so appealing as a function, and why a LoadStringEx that takes a language would really be a sensible addition to the platform.
The format of string resources is described in the MS Knowledge Base (196774) and Raymond Chen posted a good sample on how to actually use this knowledge in his post The Format of String Resources. It saves me from posting such a function here, so I will just go ahead and riff on Raymond a bit. :-)
You can also look to him for an explanation of why UnlockResource and FreeResource are no longer needed in his post The management of memory for resources in 16-bit Windows.
In truth, all that LockResource currently does in a cast from an HGLOBAL to an LPVOID (as others have noticed, they both seem to have the same pointer), but this is a time when it is best to take as hint from the documentation and keep calling it, in case that ever changes....
This post brought to you by "ઍ" (U+0a8d, a.k.a. GUJARATI VOWEL CANDRA E)
# Mihai on 13 May 2006 4:37 PM:
# Michael S. Kaplan on 13 May 2006 4:42 PM:
# Mihai on 13 May 2006 5:35 PM:
# Michael S. Kaplan on 13 May 2006 6:05 PM:
# Dean Harding on 14 May 2006 8:42 PM:
# Centaur on 15 May 2006 3:40 AM:
2007/07/13 GetLocaleInfo for other languages?
go to newer or older post, or back to index or month or day