Archive: MUI LangString bug?


MUI LangString bug?
Hi,

I'm using a MUI multi-lingual installer.
onInit uses !insertmacro MUI_LANGDLL_DISPLAY to present the user with a list of languages, after which $LANGUAGE gets populated.
Later on within the onInit function I am checking whether the application being installed is already present and running. If so, MessageBox is used to request the user to close it, so that it could be upgraded smoothly. There is a loop that ensures that the user really closes the application before proceeding.
The problem is that the MessageBox text is multilingual and thus references $(AppIsRunningMessage), which is a LangString defined previously for each applicable language. However, there seems to be a bug in which the $() always returns the English version of the message regardless of the value of $LANGUAGE. I am using LangStrings and $() successfully in other areas of the installer, the problem reported here occurs only in the onInit, yet I cannot rewrite the installer to do the MessageBox elsewhere.

Please let me know if there is a fix for this or a good workaround.

Thanks,
GJ


The language you set in .onInit isn't really set until .onInit ends. Therefore the language NSIS found most fit would be used for any LangString in .onInit. You can show the message in .onGUIInit or in a custom page.


Hi Kichik,

Thanks for the swift response. It's strange that $() doesn't work in .onInit because if I dump the value of $LANGUAGE itself during .onInit (e.g. in a MessageBox) I see that it does get set after the user selects the installation language. Strange. Anyway, I was able to work around the problem by displaying the MessageBox in my custom Upgrade page. But then I had to use 'Quit' instead of 'Abort' to stop installation if the user wanted to. Quick question: are there harmful side-effects that Quit has, compared to an Abort during .onInit (e.g. is it possible that temp files won't be deleted, the plugins folder won't get cleaned, etc)?

Another remaining issue is that I am doing the same thing in the uninstall, i.e. checking if the app is running and asking the user to close it if so, before proceeding. Here I populate $LANGUAGE myself from the registry in un.onInit (first thing) but again I see that $() doesn't work on LangStrings in un.onInit. This is very unfortunate.
I can't use un.onGUIInit because the compiler complains that it already exists. Is there something else I can do without rewriting my uninstall completely?

Thanks,
Gilad


$LANGUAGE is set in .onInit, but NSIS re-reads it only after .onInit. Quit doesn't have any side-effects I know of. The plug-ins directory is deleted and the bzip2 temporary file is deleted once closed anyway. Unless you put something out of $PLUGINSDIR, I don't think there should be any problem with Quit. Though I think it would be nicer for the user to click his way out of there, giving him time to see the message.

Because the MUI itself uses .onGUIInit and un.onGUIInit you should define a certain define to tell it to call your own function from its .onGUIInit. See the MUI readme for more information.


Hi Kichik,

Thanks. I have it working well now, in the install and uninstall. You have been extremely helpful. I have another question, but I will submit it separately to keep the forum organized.

GJ


OK.
I understand all. But inside .onInit and un.onInit I call MessageBox with "YES/NO" and if user press "Yes" -> abort installation/uninstallation. How can I do it (with multilangauge messagebox text)?


Your only option is comparing $LANGUAGE to language ids and displaying the correct message. If you use the LogicLib, it shouldn't be too complicated.