LRaiz
25th April 2006 01:32 UTC
How NSIS handles OS language?
Hello,
I am a NSIS newbie and would like some guidance regarding handling of OS language. My installer is written using MUI and at the moment works only in English. It checks and if necessary installs .NET 2.0 but since I handle only English version of .NET I would like to make sure and abort the installer on in case of non-English OS. Do I need to code this logic by hand (and detect OS Language in .onInit) or NSIS engine would do me a favor and automatically abort installation on non-English OS?
Thanks
LRaiz
25th April 2006 18:53 UTC
Thanks for the suggestion but I am not sure if MoreInfo::GetOSUserinterfaceLanguage answers my question.
According to plug-in documentation this function returns GUI Language suitable for NSIS that is determined by the algorithm -
When the installer starts up it goes through these steps to select the interface language:
1. Get user's default Windows OS GUI language
2. Find a perfect match for the langauge
3. If there is no perfect match, find a primary language match
4. If there is no match, use the first language defined in the script (make sure your first language is a common one like English)
5. If the langauge variable $LANGUAGE has changed during .onInit, NSIS goes through steps 2 to 4 again, as in the case of this plugin.
As you can see the outcome of a chosen language is never un-expected.
But in reality I don't want steps 4-5. My installer has only one language - "English", so step 4 will always guarantee that I will get it. However I don't want to install English .NET 2.0 on non-English computer. That would seriously mess up user machine. Is there an easy way to force installer to abort on non-English machine or do I have to implement it from scratch?
Afrow UK
25th April 2006 21:13 UTC
System::Call `kernel32::GetUserDefaultUILanguage() i.s`
Pop $R0 # $R0 == 1033
Either use GetUserDefaultUILanguage (as shown) or GetSystemDefaultUILanguage.
Edit: Note that this function does not exist on Windows 95 or NT.
http://support.microsoft.com/default...NoWebContent=1
-Stu
LRaiz
25th April 2006 21:18 UTC
Thanks
vpupkin
15th November 2012 17:05 UTC
Why don't NSIS use GetSystemDefaultLCID for language selection? Most software does that to detect correct language for systems with English UI and non-English locale. NSIS fails here.
Nevermind, found an easy way to achieve this:
Function .onInit
; Language detection
System::Call 'kernel32::GetSystemDefaultLangID() i.a'
FunctionEnd