Archive: MUI_LANGUAGE and LANGSTRING


MUI_LANGUAGE and LANGSTRING
  From the tutorials I deduce that MUI_LANGUAGE sets the LANGUAGE ID. That would mean that in the following code, the ID would be set to "french".
However, the message that appears is "English message". Even weirder, when I comment out
"!insertmacro MUI_LANGUAGE "French"
the message that appears is "French message".

I assumed that by setting the language, by means of
"!insertmacro MUI_LANGUAGE "xxx" "
later, when defining a string by means of LangString, automatically the one corresponding to language "xxx" will be used.


nsh 

>!include LogicLib.nsh

Name "meta"
>OutFile "meta.exe"

>;--------------------------------

!insertmacro MUI_PAGE_INSTFILES

>;--------------------------------
;
Languages !!! After INST_FILES...

!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"

>;--------------------------------
;Language strings

LangString message${LANG_ENGLISH} "English message"
>LangString message ${LANG_FRENCH} "French message"

>;--------------------------------
;Installer Sections

Section"Dummy Section" SecDummy

MessageBox MB_OK "A translated message: $(message)"

>SectionEnd
>

Well, I found some sort of solution, although I am not
sure it´s the most correct one. It surely is not mentioned
in the documentation. With the following in .onInit, one
can influence which language is used after all...



onInit


StrCpy $LANGUAGE${LANG_FRENCH}

>FunctionEnd
>

MUI_LANGUAGE doesn't set the language, it loads the language files. To set the language, you indeed need to modify $LANGUAGE in .onInit. You can find more information under Language Selection in the documentation.


I am setting the language via $LANGUAGE in .onInit. When I call $(someLS) in .onInit, it returns the "first language version", doesn't matter which language I set. If I use $(someLS) later (e.g. in Section), it works and returns correct string.

I have solution - put custom page as a first page of installer and do the work with $(someLS) there instead of doing it in .onInit.

Why I can't use LangStrings in .onInit immediately after setting the $LANGUAGE?

P.S.: When I try to have .onInit and .onGUIInit together, the compiler says that Function named ".onGUIInit" already exists.


Modern UI uses .onGUIInit internally. Use !define MUI_CUSTOMFUNCTION_GUIINIT MyGuiInit to define your own.

Stu


Thanks Afrow, but I am interested in language strings. Can you answer my previous question?


You can't use language strings in .onInit, the language is initialised after .onInit.

You must use a LogicLib Switch/Select with $LANGUAGE.


${Switch} $LANGUAGE
${Case} ${LANG_ENGLISH}
...
${Break}
${Case} ${LANG_FRENCH}
...
${Break}
${EndSwitch}


Stu