Archive: How to set language in .onInit function?


How to set language in .onInit function?
If already installed, there should be a language id in the registry. We can use "!insertmacro MUI_UNGETLANGUAGE" in un.onInit function. But how to set the right language in .onInit function?

I want to display a messagebox in .onInit function to confirm uninstall if it's already installed. Of course, I want the messagebox in multi-language like:

MessageBox MB_OKCANCEL|MB_ICONQUESTION|MB_DEFBUTTON2 "$(UninstallConfirm)" IDOK uninst

But how to set the right language? MUI_UNGETLANGUAGE has no effect in .onInit function. And I try to use StrCpy set $LANGUAGE var and there was also no effect.


If you're using MUI_UNGETLANGUAGE, I presume you're also using..


MUI_LANGDLL_REGISTRY_ROOT root
MUI_LANGDLL_REGISTRY_KEY key
MUI_LANGDLL_REGISTRY_VALUENAME value_name

In the installer to store that setting.

Instead of letting MUI read the value, you could read it yourself.

However, MUI should already be using the language stored in that registry key automatically... if it doesn't for that messagebox at .onInit, then I suppose you will indeed have to go with manually reading out the value and applying the appropriate language before the messagebox is displayed.

from the helpfile

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.
you can use .onGuiInit (but why is the uninstall confirm page not enough?)

Thanks for reply.

Yes, I read the language manually but this is not the problem, the problem is even I set the $LANGUAGE, MessageBox also not display the right language:


Function .onInit
StrCpy $LANGUAGE ${LANG_SIMPCHINESE}
MessageBox MB_OKCANCEL|MB_ICONQUESTION|MB_DEFBUTTON2 "$(UninstallConfirm)" IDOK uninst
FunctionEnd


It's english, and my system is english.

The uninstall confirm page is displayed when uninstall is processing. But I need to confirm if uninstall when user run install.exe for twice(when he already installed), not run uninstall.exe, thanks.

Use un.onGUIInit (!define MUI_CUSTOMFUNCTION_UNGUIINIT un.myOnGUIInit). Languages are not initialised until after .onInit.

Stu


Thanks for all! .onGuiInit and un.onGUIInit is good, I've done, thanks.