Archive: Possibility to define multilanguage io.ini's


Possibility to define multilanguage io.ini's
  Dear community -

Is there a way to make io.ini output multi-lingual?

I have some CutomPages which work pretty fine, but there are some "Type=label" with "Text=...". How can this be *lingualized* too? So if languageA is choosen at installation time, languageA "Text=..." should be displayed. If languageB is choosen ... (and so on)

Any ideas
Thx
Chris


Use language strings, and write the translated string to a INI file.

Example:


LangString Field1_Text ${LANG_ENGLISH} "English text:"

>LangString Field1_Text ${LANG_FRENCH} "French text:"

>Function "Your Page Function"

!insertmacro MUI_INSTALLOPTIONS_WRITE "io.ini" "Field 1" "Text" "$(Field1_Text)"

>;other things here!

>FunctionEnd
>

Cool,

thx deguix!


One short question (sorry)

This is the start of the section


  Section....

!
insertmacro MUI_INSTALLOPTIONS_READ $R0 "ioA.ini" "Field 3" "State"
StrCmp $R0 1 "" noOption1 ;check whether the option is selected
>
Where do I have to place your directives
(you told before)?

Or replace !insertmacro MUI_INSTALLOPTIONS_READ with !insertmacro MUI_INSTALLOPTIONS_WRITE

Chris

If you want to only replace the text if the option is selected, add the:

!insertmacro MUI_INSTALLOPTIONS_WRITE "inifile.ini" "Field #" "Text" "$(LanguageString)"


OK I am too stup**&% for that.

I packed the entire state of my installer as zip (attached).

When you compile it (should work with every default NSIS installation) you see on CustomPageA the description is in english (doesn't matter if german is selected or english) On CustomPageB everything appears in german, even if english is selected.
The shown strings are "hard coded" in the ioA/B.ini, so this behaviour is what I had to expect.

So far so good, but the translation should appear in the selected language (as you would expect). Where must I change my code?

If possible, please be as descriptive as possible. As you already know I am a /(&%*'$ยง"-Programmer
:(

Thx Chris


* Remove '!insertmacro MUI_INTERFACE' from your script. You don't have to insert that macro (probably old alpha 7 code).

* Add the language strings somewhere in your script (a good place is in the configuaration):

LangString Field1_Text ${LANG_ENGLISH} "English text:"
LangString Field1_Text ${LANG_FRENCH} "French text:"

* Add the write macro in .onInit after extracting the IO files:

!insertmacro MUI_INSTALLOPTIONS_WRITE "io.ini" "Field 1" "Text" "$(Field1_Text)"


Do I need the red line?

[Field 2]
Type=Label
Text=Hello World.
Left=10
Right=-10
Top=11
Bottom=27

Or must I leave it empty or delete it?


---[UPDATE]-----

Oh I got it....
Is the macro preferred? I had the text defined both, in io.ini and as you mentioned above. The preferred was the defined with
  !insertmacro MUI_INSTALLOPTIONS_WRITE "ioB.ini" "Field 1" "Text" "$(Field1_Text)"

Jost -

Major 'genius' Dude

:D


Putting the code in .onInit won't work as the final language is set only after .onInit. Put it in .onGUIInit or in custom page's creator function before calling to InstallOptions.


That's right,

I put it after .onInit and the only language shown is the first set.

KichiK -
What's the "custom pages's creator function"?


The function where you create the InstallOptions page. For example:


Page custom CreatorFunction

>Function CreatorFunction
# show io...
>FunctionEnd
>

Using .onGuiInit is better because it will only be set once. You can remove the Text from the INI file.

For the Modern UI, use:

!define MUI_CUSTOMFUNCTION_GUIINIT SetIOText

Function SetIOText

...the write macro's...

FunctionEnd

If you take a look at the attached file posted some posts before, ther is no such function or am I wrong?

The .onGUIInit won't work for me. It says already defined, but I can't find it ...
:igor:


The Modern UI defines .onGUIInit, you have to define your own custom funtion and add it, have a look at the example above :)

There define should be inserted before the MUI_LANGUAGE macro's. You can put the funtion anywhere in your script.


Good god -

it works, buhuuuuu!:cry:

Felt like a 30 year old child:
Dad, I want this matchbox car!

Thx guys
Chris