Archive: Changing the language on the fly.


Changing the language on the fly.
I am trying to make a mutli language installer using the modern UI however I want to have the language selection box on the welcome page.

Now I managed to get a drop down box on the Welcome page that will allow them to select a language but I get an error if i try doing !insertmacro MUI_LANGUAGE "$Lang" or any combination that I can think of.

Does anyone know how to do this? It doesn't even need to change the welcome page through that would be nice if it could.


You can't do that. The language can only be selected in .onInit. If you really want, you can wrap the real installer in an installer that shows this welcome page and passes the selection to the wrapped installer.


well if I was to use !insertmacro MUI_LANGDLL_DISPLAY to display the choose a language option before the welcome page is there anyway to get what language they choose. I need that because I set the language that my program is in.


$LANGUAGE contains the selected language id.


thanks


Hi mscoville, I hope kichik will not get mad ;) since I post the moreinfo plugin as a possible solution to your problem again.
If you would be contend that the OS GUI language, that is the part that people need to understand before being able to use a OS GUI anyway.
Just embed the languagus you want to support, get the OS GUI languageID and set this language. It's is best just to read the Moreinfo plugin documentation on the Wiki and try it, can save you a lot of time.

I wish you success and thank you for using NSIS as an installer solution.


okay I tried doing it using the MUI_LANGDLL_DISPLAY and $LANGUAGE contains a number so where can I find the language codes or is there any way to convert this back to the language that was choosen. I'd rather just be able to convert it back into the language without having to know the number for each language so that I only have to edit it in one place when we add more languages.


You can use LogicLib to create a switch and the LANG_* defines:

!include LogicLib.nsh
# ...
${Switch} $LANGUAGE
${Case} ${LANG_ENGLISH}
MessageBox MB_OK "English"
${Break}
${Case} ${LANG_FRENCH}
MessageBox MB_OK "French"
${Break}
${EndSwitch}

okay well I found a list of the codes would still like to know if there is any easy way without doing a comparsion to convert the code into the name of the language.

ie 1033 is english and I would like the installer to know that when they choose english to use it later in my setting.

looking at the page for moreinfo says

Several CD/DVD methods and properties return locale identifier (LCID) values that identify which languages are available on the soundtracks or subtitles. To make use of this information, your application will need to extract the primary language ID from the returned LCID. To do this, perform a bitwise AND operation on the value of iLCID and $3FF. (The primary language ID is contained in the least significant 10 bits of the LCID.) The following code snippet shows how to do this.

iPrimaryLang = iLCID & $3FF;

To obtain an human-readable string from the primary language ID, call GetLangFromLangID as shown in this example:

sLanguage = DVD.GetLangFromLangID(iPrimaryLang);
 

but I'm getting an error on iPrimaryLang

Invalid command: iPrimaryLang
Error in script

Originally posted by kichik
You can use LogicLib to create a switch and the LANG_* defines:
!include LogicLib.nsh
# ...
${Switch} $LANGUAGE
${Case} ${LANG_ENGLISH}
MessageBox MB_OK "English"
${Break}
${Case} ${LANG_FRENCH}
MessageBox MB_OK "French"
${Break}
${EndSwitch}
thanks will try that.