Hi,
I'm sorry to bug you all with this new topic, but I am a newbie and I didn't quite understand the other posts about this.
The problem I have is that I need to split my installer according to the language selected by the user during .oninit.
I am using:
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
After the language is selected by the user I need to have different sections for each language selection. The problem I have is that I do not know how to recognize the language the user has selected, so that it will point to a section or another. Thanks a lot for the help.
output files altered by language selection
39 posts
you can query the $LANGUAGE variable
Thanks for the quick reply. any help on how I could do that, because I didn't get much from that link (I read it over and over again before, thanks... )
What is it mean
After the language is selected by the user I need to have different sections for each language selection.Is you want different sections names or other?
What I mean is that when a language is selected, my program will install different files. Each language has something different, so I can't install the whole package, I need the option in the installer...
You can use in section:
All languages ID you can find using MakeLangID-tool or in language files.
ADD:
StrCmp $LANGUAGE 1033 0 ruslang
... install some english files ....
ruslang:
StrCmp $LANGUAGE 1049 0 germanlang
... install some russian files ....
germanlang:
StrCmp $LANGUAGE 1031 0 otherlang
... install some german files ....
otherlang:
All languages ID you can find using MakeLangID-tool or in language files.
Thanks a lot. It helped me, and it now works.
Make sure you put some Goto's in there so it doesn't go through the whole StrCmp group:
StrCmp $LANGUAGE 1033 0 ruslang
... install some english files ....
Goto End
ruslang:
StrCmp $LANGUAGE 1049 0 germanlang
... install some russian files ....
Goto End
germanlang:
StrCmp $LANGUAGE 1031 0 otherlang
... install some german files ....
Goto End
otherlang:
End:
-Stu
StrCmp $LANGUAGE 1033 0 ruslang
... install some english files ....
Goto End
ruslang:
StrCmp $LANGUAGE 1049 0 germanlang
... install some russian files ....
Goto End
germanlang:
StrCmp $LANGUAGE 1031 0 otherlang
... install some german files ....
Goto End
otherlang:
End:
-Stu
Or simply use the LogicLib:
!include LogicLib.nsh
#...
${Switch} $LANGUAGE
${Case} ${LANG_ENGLISH}
File en.txt
${Break}
${Case} ${LANG_FRENCH}
File fr.txt
${Break}
${Case} ${LANG_HEBREW}
File he.txt
${Break}
${EndSwitch}
Thanks, I think I'll write the whole thing again. 🙂
Hey, I have one more question.
My installer uses in .onInit some message boxes. How can I alter them using the language selection? I already used langstring and added a message for each language, but it won't display in .onInit.
Thanks
My installer uses in .onInit some message boxes. How can I alter them using the language selection? I already used langstring and added a message for each language, but it won't display in .onInit.
Thanks
Originally posted by cri_nedMessageboxes didn't display or they displayed but with not correct language?
I already used langstring and added a message for each language, but it won't display in .onInit.
Messageboxes are displayed, but are in the default language, in English. I wondered if I could change that. I tried adding a section, but the message box did not display...
Could someone please help me on how to use this piece of code for my situation? I need to choose the language from the command line, but I don't quite get how to use the code.
; GetParameters
; input, none
; output, top of stack (replaces, with e.g. whatever)
; modifies no other variables.
Function GetParameters
Push $R0
Push $R1
Push $R2
Push $R3
StrCpy $R2 1
StrLen $R3 $CMDLINE
;Check for quote or space
StrCpy $R0 $CMDLINE $R2
StrCmp $R0 '"' 0 +3
StrCpy $R1 '"'
Goto loop
StrCpy $R1 " "
loop:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 $R1 get
StrCmp $R2 $R3 get
Goto loop
get:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 " " get
StrCpy $R0 $CMDLINE "" $R2
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
; GetParameters
; input, none
; output, top of stack (replaces, with e.g. whatever)
; modifies no other variables.
Function GetParameters
Push $R0
Push $R1
Push $R2
Push $R3
StrCpy $R2 1
StrLen $R3 $CMDLINE
;Check for quote or space
StrCpy $R0 $CMDLINE $R2
StrCmp $R0 '"' 0 +3
StrCpy $R1 '"'
Goto loop
StrCpy $R1 " "
loop:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 $R1 get
StrCmp $R2 $R3 get
Goto loop
get:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 " " get
StrCpy $R0 $CMDLINE "" $R2
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
Put in .onInit
Command line must be
Add ${Case} "..." for other languages.
Call GetParameters
Pop $R0
${Switch} $R0
${Case} "english"
StrCpy $Language ${LANG_ENGLISH}
${Break}
${Case} "french"
StrCpy $Language ${LANG_FRENCH}
${Break}
${EndSwitch}
Command line must be
outfile.exe language
Thanks glory. Should I leave the getparams function like that, or do I have to make it look like the piece of code you sent me? I'm sorry to bug you, but I'm quite a noob... 😕
As i understand - this is function from NSIS docs. So put function's code into your script and include my code into .onInit function. Don't forget
if it is not present.include LogicLib.nsh
Small typo: !include LogicLib.nsh
-Stu
-Stu
Hi, thanks to all for the replies. Now I'm facing a different problem. It will only install in English, and it won't write the registry key for the language.
I use this code:
StrCmp $LANGUAGE 1033 0 ruslang
... install some english files ....
Goto End
ruslang:
StrCmp $LANGUAGE 1049 0 germanlang
... install some russian files ....
Goto End
germanlang:
StrCmp $LANGUAGE 1031 0 otherlang
... install some german files ....
Goto End
otherlang:
End:
, from Stu (thanks btw)
Also, in order to write the reg key for the uninstaller I use:
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "something..."
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
.
The code for the command line selection is:
Call GetParameters
Pop $R0
${Switch} $R0
${Case} "en"
StrCpy $Language ${LANG_ENGLISH}
${Break}
${Case} "fr"
StrCpy $Language ${LANG_FRENCH}
${Break}
and some other languages, written just the same way
${EndSwitch}
in other words, I'm stuck again.
Ps, I did !include LogicLib.nsh
I use this code:
StrCmp $LANGUAGE 1033 0 ruslang
... install some english files ....
Goto End
ruslang:
StrCmp $LANGUAGE 1049 0 germanlang
... install some russian files ....
Goto End
germanlang:
StrCmp $LANGUAGE 1031 0 otherlang
... install some german files ....
Goto End
otherlang:
End:
, from Stu (thanks btw)
Also, in order to write the reg key for the uninstaller I use:
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "something..."
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
.
The code for the command line selection is:
Call GetParameters
Pop $R0
${Switch} $R0
${Case} "en"
StrCpy $Language ${LANG_ENGLISH}
${Break}
${Case} "fr"
StrCpy $Language ${LANG_FRENCH}
${Break}
and some other languages, written just the same way
${EndSwitch}
in other words, I'm stuck again.
Ps, I did !include LogicLib.nsh
Ok, it now works. I wasn't waiting for the installer to do what it was supposed to.
The only problem I've got left is with the registry. It won't write the language in which it is installed, and when uninstalling it will ask for a selection...
The only problem I've got left is with the registry. It won't write the language in which it is installed, and when uninstalling it will ask for a selection...
Is it possible to also add a rule in which case if there is no parameter, the default value would be to install in English? Because at this point if I use no parameter it will install in the default windows language... and I don't want it to act like this.... Thanks.
Instead this rule
${Case} "en"
StrCpy $Language ${LANG_ENGLISH}
${Break}
you can use
${Default}
StrCpy $Language ${LANG_ENGLISH}
${Break}
As for the registry, there's Modern UI Examples which do this for you.Call GetParamaters
Pop $R0
StrCmp $R0
StrCpy $LANGUAGE ${LANG_ENGLISH}
-Stu
Hi, thanks for the quick help.
The problem with the uninstall is that if I leave !insertmacro MUI_UNGETLANGUAGE it will use the default windows language. If I comment it, it will ask for the language it should display. I cannot get it to write in the registry the language key, as explained in the Modern UI examples...
The problem with the uninstall is that if I leave !insertmacro MUI_UNGETLANGUAGE it will use the default windows language. If I comment it, it will ask for the language it should display. I cannot get it to write in the registry the language key, as explained in the Modern UI examples...
MUI_UNGETLANGUAGE should use register keys specified with MUI_LANGDLL_REGISTRY_ROOT, MUI_LANGDLL_REGISTRY_KEY, MUI_LANGDLL_REGISTRY_VALUENAME defines.
Add:
Maybe you do not save them during installation.
Add:
Maybe you do not save them during installation.
I already have
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "the software location..."
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
The problem is it doesn't save them... does it matter if this code is before the get params function?
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "the software location..."
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
The problem is it doesn't save them... does it matter if this code is before the get params function?
These defines should be set before inserting the installation page macro.
Yup, it's before. And it still doesn't write it in the registry... Could it be because of the fact that I'm choosing the language with this code?
Call GetParameters
Pop $R0
${Switch} $R0
${Case} "en"
StrCpy $Language ${LANG_ENGLISH}
${Break}
${Case} "fr"
StrCpy $Language ${LANG_FRENCH}
${Break}
and some other languages, written just the same way
${EndSwitch}
Call GetParameters
Pop $R0
${Switch} $R0
${Case} "en"
StrCpy $Language ${LANG_ENGLISH}
${Break}
${Case} "fr"
StrCpy $Language ${LANG_FRENCH}
${Break}
and some other languages, written just the same way
${EndSwitch}
Could you write a cut down script which causes this problem?
-Stu
-Stu