Old 5th May 2005, 12:52   #1
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
Unhappy output files altered by language selection

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.
cri_ned is offline   Reply With Quote
Old 5th May 2005, 12:55   #2
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,366
you can query the $LANGUAGE variable
Yathosho is offline   Reply With Quote
Old 5th May 2005, 13:00   #3
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
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... )
cri_ned is offline   Reply With Quote
Old 5th May 2005, 13:10   #4
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
What is it mean
Quote:
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?
glory_man is offline   Reply With Quote
Old 5th May 2005, 13:17   #5
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
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...
cri_ned is offline   Reply With Quote
Old 5th May 2005, 13:24   #6
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
You can use in section:
code:

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:



ADD:
All languages ID you can find using MakeLangID-tool or in language files.
glory_man is offline   Reply With Quote
Old 5th May 2005, 13:42   #7
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
Thanks a lot. It helped me, and it now works.
cri_ned is offline   Reply With Quote
Old 5th May 2005, 15:01   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 5th May 2005, 17:02   #9
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Or simply use the LogicLib:
code:
!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}


NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 10th May 2005, 13:05   #10
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
Smile

Thanks, I think I'll write the whole thing again.
cri_ned is offline   Reply With Quote
Old 16th May 2005, 12:57   #11
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
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
cri_ned is offline   Reply With Quote
Old 16th May 2005, 13:55   #12
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
Quote:
Originally posted by cri_ned
I already used langstring and added a message for each language, but it won't display in .onInit.
Messageboxes didn't display or they displayed but with not correct language?
glory_man is offline   Reply With Quote
Old 16th May 2005, 14:00   #13
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
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...
cri_ned is offline   Reply With Quote
Old 16th May 2005, 14:09   #14
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
This problem was discussed. In .onInit you can compare $LANGUAGE with language id.
Try this and this links.
And try to search for forum with "MessageBox" and "multilanguage" or ".onInit" for more examples.
glory_man is offline   Reply With Quote
Old 6th June 2005, 15:00   #15
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
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
cri_ned is offline   Reply With Quote
Old 6th June 2005, 15:59   #16
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
Put in .onInit
code:

Call GetParameters
Pop $R0
${Switch} $R0
${Case} "english"
StrCpy $Language ${LANG_ENGLISH}
${Break}
${Case} "french"
StrCpy $Language ${LANG_FRENCH}
${Break}
${EndSwitch}


Add ${Case} "..." for other languages.
Command line must be
code:
outfile.exe language
glory_man is offline   Reply With Quote
Old 7th June 2005, 07:15   #17
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
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...
cri_ned is offline   Reply With Quote
Old 7th June 2005, 11:27   #18
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
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
code:
include LogicLib.nsh
if it is not present.
glory_man is offline   Reply With Quote
Old 7th June 2005, 13:00   #19
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Small typo: !include LogicLib.nsh

-Stu
Afrow UK is offline   Reply With Quote
Old 7th June 2005, 13:57   #20
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
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
cri_ned is offline   Reply With Quote
Old 8th June 2005, 07:19   #21
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
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...
cri_ned is offline   Reply With Quote
Old 7th July 2005, 13:22   #22
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
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.
cri_ned is offline   Reply With Quote
Old 7th July 2005, 14:24   #23
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
Instead this rule
code:
${Case} "en"
StrCpy $Language ${LANG_ENGLISH}
${Break}


you can use
code:

${Default}
StrCpy $Language ${LANG_ENGLISH}
${Break}

glory_man is offline   Reply With Quote
Old 7th July 2005, 14:25   #24
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
code:
Call GetParamaters
Pop $R0
StrCmp $R0
StrCpy $LANGUAGE ${LANG_ENGLISH}



As for the registry, there's Modern UI Examples which do this for you.

-Stu
Afrow UK is offline   Reply With Quote
Old 11th July 2005, 14:03   #25
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
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...
cri_ned is offline   Reply With Quote
Old 11th July 2005, 14:16   #26
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
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.
glory_man is offline   Reply With Quote
Old 12th July 2005, 11:15   #27
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
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?
cri_ned is offline   Reply With Quote
Old 12th July 2005, 12:16   #28
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
These defines should be set before inserting the installation page macro.
glory_man is offline   Reply With Quote
Old 12th July 2005, 12:24   #29
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
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}
cri_ned is offline   Reply With Quote
Old 12th July 2005, 13:00   #30
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Could you write a cut down script which causes this problem?

-Stu
Afrow UK is offline   Reply With Quote
Old 12th July 2005, 13:03   #31
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
Try to change ${Case} "en" -> ${Default}.
glory_man is offline   Reply With Quote
Old 13th July 2005, 09:26   #32
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
Well I have the begining of the script, with some dfines, including some variables of my own, for when specific situations occur, like:

!define AFFILIATE_STRING "something..."

!define ENGLISH_LANGUAGE
!define FRENCH_LANGUAGE
!define GERMAN_LANGUAGE
!define SPANISH_LANGUAGE
!define DUTCH_LANGUAGE
!define DANISH_LANGUAGE
!define SWEDISH_LANGUAGE
(I am not always using all the languages)

!define SILENT_BUILD


after this I have:

!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "something..."
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"

After that are the name and all, and the get params as seen here, as long with the on init part of getparams:

in oninit I have this:

!ifdef SILENT_BUILD
Call GetParameters

Pop $R0
${Switch} $R0

${Default}
StrCpy $Language ${LANG_ENGLISH}
${Break}

${Case} "/fr"
StrCpy $Language ${LANG_FRENCH}
${Break}

${Case} "/de"
StrCpy $Language ${LANG_GERMAN}
${Break}

${Case} "/es"
StrCpy $Language ${LANG_SPANISH}
${Break}

${Case} "/nl"
StrCpy $Language ${LANG_DUTCH}
${Break}

${Case} "/dk"
StrCpy $Language ${LANG_DANISH}
${Break}

${Case} "/se"
StrCpy $Language ${LANG_SWEDISH}
${Break}

${EndSwitch}

!endif

The install part works ok, I don't have any errors or anything. The problem is with the uninstall.

in un.oninit I have this as the first line:

!insertmacro MUI_UNGETLANGUAGE
.

If left like this, it will ask to pick the language. If commented, it will use the default windows language, not the one picked for the install.

That is where I have the problem...

Thanks a lot for the help.
Cristi
cri_ned is offline   Reply With Quote
Old 19th July 2005, 10:42   #33
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
Hi,

Me again

any ideea, or is it something like a bug?

I still haven't found out why it doesn't write the registry key.

thanks!
cri_ned is offline   Reply With Quote
Old 19th July 2005, 12:14   #34
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
Can you attach whole script?
glory_man is offline   Reply With Quote
Old 21st July 2005, 08:16   #35
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
Hi,

I'm sorry I didn't put the script. I have to make a shorter version of it. Just to let you know, I found a fix for the problem by working around it, and reading a different registry key that my program allready put there, in order to know the language. I used this code:

ReadRegStr $0 HKCU Software\... "Language"

${If} $0 S== "en"
StrCpy $LANGUAGE ${LANG_ENGLISH}
${Else}

${If} $0 S== "fr"
StrCpy $LANGUAGE ${LANG_FRENCH}
${Else}

${If} $0 S== "se"
StrCpy $LANGUAGE ${LANG_SWEDISH}
${Else}

${If} $0 S== "de"
StrCpy $Language ${LANG_GERMAN}
${Else}

${If} $0 S== "es"
StrCpy $Language ${LANG_SPANISH}
${Else}

${If} $0 S== "nl"
StrCpy $Language ${LANG_DUTCH}
${Else}

${If} $0 S== "dk"
StrCpy $Language ${LANG_DANISH}
${Else}

${If} $0 S== "it"
StrCpy $Language ${LANG_ITALIAN}
${Else}
${EndIf}
${EndIf}
${EndIf}
${EndIf}
${EndIf}
${EndIf}
${EndIf}
${EndIf}

and the uninstaller works in what language I need. I'll put the shorter script later this week, in order to let you guys check if it is a bug or something because of me.

Cristi
cri_ned is offline   Reply With Quote
Old 21st July 2005, 10:10   #36
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
Simple comment.
Instead combination ${Else} ${If} you can use ${ElseIf} and close it with one ${EndIf}.
glory_man is offline   Reply With Quote
Old 6th September 2005, 12:37   #37
cri_ned
Junior Member
 
Join Date: May 2005
Posts: 22
Send a message via Yahoo to cri_ned
Hi all,

I have a new problem. I use a page that is from an ini. It has some text, which I need to be able to display according to the language of the installer. Is there a way to use those pages in a similar manner to this:

LicenseLangString license ${LANG_ITALIAN} "D:\...\license.txt" ?

Thanks a lot for the help guys. I don't know where my installer would be without you.
cri_ned is offline   Reply With Quote
Old 6th September 2005, 12:52   #38
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You need to write the language string to the INI file on run-time with WriteINIStr:

WriteINIStr "$PLUGINSDIR\ioFile.ini" "Field #" "Text" "$(license)"

-Stu
Afrow UK is offline   Reply With Quote
Old 15th September 2005, 15:29   #39
onad
Senior Member
 
onad's Avatar
 
Join Date: Dec 2004
Location: Turkey
Posts: 447
Lightbulb

Multilingual example in Moreinfo

Multilingual example in Moreinfo plugin. Multi language in an easy extensible way in one of the demos. Will solve a lot of multilanguage language problems.
The "CustomLanguageDemo" Fully shows the power of getting the OS GUI language. I the demo a good example of how custompage localization works and could be implemented.

See the Wikipage

http://nsis.sourceforge.net/wiki/MoreInfo_plug-in

Or take a look in:

http://forums.winamp.com/showthread...hlight=moreinfo

Just try the "CustomLanguageDemo" demo included.

"Just do it"
onad is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump