- NSIS Discussion
- Is there a way to insert specific macro language with MUI
Archive: Is there a way to insert specific macro language with MUI
webtubbies
2nd October 2009 14:36 UTC
Is there a way to insert specific macro language with MUI
Hello,
I'm trying to use the '!insertmacro MUI_LANGUAGE "myLMang"' in a specific way.
First i have one install which store the language the user chose.
!define MUI_LANGDLL_REGISTRY_ROOT HKLM
>!define MUI_LANGDLL_REGISTRY_KEY "SOFTWARE\${Registry}"
>!define MUI_LANGDLL_REGISTRY_VALUENAME "${Langinstall}"
Then the second installer get the language in the registry (i.e. 1033 for English). The installer doesn't display language listBox.
So I want insert the right language in the script (here " !insertmacro MUI_LANGUAGE "English" "
My problem is that I can't use this macro in a function and I can't use switch case out of a function.
Does anyone got an Idea to help my poor brain...?
Here's my code:
${Switch} $LANGUAGE
${Case} '1033'
!insertmacro MUI_LANGUAGE "English"
${Break}
${Case} '1036'
!insertmacro MUI_LANGUAGE "French"
${Break}
${Default}
${Break}
${EndSwitch}
pengyou
3rd October 2009 13:37 UTC
I am not sure what you are trying to do.
You have two installers. The first one offers a choice of languages (English and French?). This installer stores the selected language in the registry.
After you have run the first installer you want to run another installer. The second installer is to use whatever language was selected when the first installer was run.
I think your problem is that you do not know how to make the second installer use the correct language.
Have you looked at the multi-language MUI example that comes with NSIS?
Try compiling the Examples\Modern UI\MultiLanguage.nsi script to make the MultiLanguage.exe demo installer.
The first time I ran MultiLanguage.exe on my English version of Windows it showed a language selection dialog with "English" pre-selected. I used the dialog box to select "French" and ran the demo installer (and all the pages were in French).
After the installer finished, I ran MultiLanguage.exe again. This time it did not show the language selection dialog so the very first thing that appeared was the License page and that was all in French (even though I was running it on an English version of Windows). This happened because the installer was using the language setting stored in the registry.
Yathosho
3rd October 2009 18:59 UTC
leave your macros outside the section, where they belong. to switch the language you just need to do this:
StrCpy $LANGUAGE "1033"
i guess you have to use this before your GUI is initialized (onInit or onGUIInit).
unless you need the language stores in the registry permanently, i think it's good practice to execut second installer with a parameter (mySetup.exe /L=1033).
http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.12
webtubbies
5th October 2009 08:56 UTC
Originally posted by pengyou
I am not sure what you are trying to do.
You have two installers. The first one offers a choice of languages (English and French?). This installer stores the selected language in the registry.
After you have run the first installer you want to run another installer. The second installer is to use whatever language was selected when the first installer was run.
Yes that's the point. I have to have a close look to the example MultiLanguage.nsi.
to switch the language you just need to do this:
code:--------------------------------------------------------------------------------StrCpy $LANGUAGE "1033"--------------------------------------------------------------------------------
i guess you have to use this before your GUI is initialized (onInit or onGUIInit).
That's what I've done with no success...
Use the switch /L with the installer is a good advice. I'll try it. But at this time it's an external program (i.e. I can't handle it) which calls my second installer.
Thank you both. I'll be back to tell you if i can find a fix :)
webtubbies
5th October 2009 09:55 UTC
Ok, It's working now.
What I have done in the second installer is:
Put these lines:
!define MUI_LANGDLL_REGISTRY_ROOT HKLM
>!define MUI_LANGDLL_REGISTRY_KEY "SOFTWARE\${Registry}"
>!define MUI_LANGDLL_REGISTRY_VALUENAME "${Langinstall}"
then in the OnInit:
insertmacro MUI_LANGDLL_DISPLAY
>
First I thought,that copying the registry value (1033 or 1036) in the $LANGUAGE variable was enough.
According to the MUI documentation:
!If you want the installer to display a language selection dialog (see the the MultiLanguage.nsi example), insert the MUI_LANGDLL_DISPLAY macro in the .onInit function
So i don't understand why I have to insert this code, because I don't want the language listBox. And in this case it's not shown... Did I miss something?
Anyhow, it's working now.
Thank You.
pengyou
5th October 2009 11:13 UTC
So i don't understand why I have to insert this code, because I don't want the language listBox. And in this case it's not shown... Did I miss something?
The language selection dialog will only appear if no language setting is found in the registry. I mentioned this in my earlier message (the first time I ran the demo I saw the dialog but the second time I ran the demo the box did not appear).
There is another MUI setting you can use if you ALWAYS want the language selection dialog to appear. See the MUI readme:
To customize the language selection dialog interface, use these defines before inserting the MUI_LANGDLL_DISPLAY macro.
MUI_LANGDLL_ALWAYSSHOW
Always show the language selection dialog, even if a language has been stored in the registry. The language stored in the registry will be selected by default.
webtubbies
5th October 2009 11:26 UTC
Damn,
I did not read the entire section. Sorry about that.
pengyou
5th October 2009 11:36 UTC
Don't worry about that. I have read the documents lots of times and still find new things in them.