Archive: Section text unchanged (MUI/.onInit)


Section text unchanged (MUI/.onInit)
Hi all, i would need a little help for a problem i could not find a response despite search

briefly, im trying to change Section title dynamically (calling function in .oninit) in MUI interface, using this syntax:

SectionSetText ${_section_X} "$(XTitle)"

where XTitle is define in langstring external file as:
LangString XTitle ${LANG_GERMAN} "XGerman"
LangString XTitle ${LANG_FRENCH} "XFrench"


Actually i've defined all sections titles that way, and their title is changing correctly with selected language except the one that i am trying to change dynamically at runtime

Sections are all defined that way
Section "$(XTitle)" _section_X

> is there an order in .onInit to respect for calling my function and !insertmacro MUI_LANGDLL_DISPLAY (if concerned ?)

In fact, the section text is always the last language in alphabetic order of language selection box (in my example, it is always XFrench, even when i choose German)

Thx for tips !


Languages are not initialised until after .onInit. Do language strings not work in section names?

Stu


They do work in section names for 'static' sections
To be more explicit, this an example

In langstring.nsh i declare:
LangString XTitle ${LANG_GERMAN} "XGerman"
LangString XTitle ${LANG_FRENCH} "XFrench"
LangString YTitle ${LANG_GERMAN} "YGerman"
LangString YTitle ${LANG_FRENCH} "YFrench"


In main script file i have:
; Languages
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "French"

; Language translations
!insertmacro MUI_RESERVEFILE_LANGDLL
!include ".\langstrings.nsh"

....

Section "$(XTitle)" _section_X
...

Section "$(YTitle)" _section_Y
...

Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
;SectionSetText ${_section_X} "$(XTitle) XXXXX"
FunctionEnd



--> Ytitle is correctly translated, i have "YGerman" or "YFrench" when i choose German or French

--> XTitle is ALWAYS "XFrench XXXXX" whenever i choose German or French !


if any idea ...


thx 4 answer Afro, you right

LangString:
"If you change the language in the .onInit function, note that language strings in .onInit will still use the detected language based on the user's default Windows language, because the language is initialized after .onInit."

Need to find a solution now :P


Anywhere before you show the components page will be fine. .onGUIInit is a start (MUI_CUSTOMFUNCTION_GUIINIT for Modern UI).

Stu