- NSIS Discussion
- LangString problem
Archive: LangString problem
IceRAM
7th January 2004 19:49 UTC
LangString problem
I've got a problem using LangString:
1. define a variable using LangString for language LANG1
2. start the installer and choose LANG2 using MUI
3. strings show in System language, not the LANG2, the one chosed on startup (fortunately, it was LANG1).
4. when tried on a computer that has a different default language (LANG3), the strings were empty.
Note that there were no strings defined for LANG3.
It is terribly annoying seeing that, after choosing a language on the startup of the installer, the LangStrings show in the system's language.
What happens if the strings for a language (doesn't matter the way the language is checked) are not defined - running the installer on a system with LANG3, LANG3 chosen on startup, but no LangStrings defined for LANG3.
Joost Verburg
7th January 2004 20:04 UTC
That's definately not a NSIS issue. You will have to attach your script so I see what you are doing wrong.
IceRAM
7th January 2004 21:44 UTC
the script is quite big.
here's a small script that has the same problem
--- SCRIPT ---
!include "MUI.nsh"
Name "testLangString"
OutFile "testLangString.exe"
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Polish"
!insertmacro MUI_LANGUAGE "Romanian"
!insertmacro MUI_RESERVEFILE_LANGDLL
LangString VAR1 ${LANG_POLISH} "POLISH is set"
LangString VAR1 ${LANG_ENGLISH} "ENGLISH is set"
Section dummy
SectionEnd
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
MessageBox MB_OK $(VAR1)
FunctionEnd
--- END SCRIPT ---
Questions:
1. My system is set to English. When I choose Polish, I see the English message. Shouldn't I see the Polish one?
2. Shouldn't there be a default language when I choose "Romanian" for example? I'd like to see English by default for example.
As a side effect to 1, if the system has a language that does not have a corresponding LangString, the variable won't contain any of the strings, it would be null.
If I don't have a default lang for langstrings, I have to use preinitialized variables and that change WHEN the langstring variable is not null.
Joost Verburg
7th January 2004 22:23 UTC
1. You can't use language strings in .onInit, the language is initialised after .onInit.
2. Set a string for all languages.
IceRAM
7th January 2004 22:34 UTC
Originally posted by Joost Verburg
1. You can't use language strings in .onInit, the language is initialised after .onInit.
Hmm.. I have message boxes in .onInit that need translation (warning for multiple installer sessions, close specific application and so on).
Ok.. assuming I move *all* the code from onInit, which is the next function which is called (before showing any PAGEs) that has the language strings enabled?
Originally posted by Joost Verburg
2. Set a string for all languages.
How come?
StrCpy ${VAR1} "text" ? or
StrCpy $(VAR1) "text" ? or.. some other method?
P.S.:
(1) & (2) should be documented.. somewhere. (I don't think I've missed something about LangStrings in the docs).
s793016
8th January 2004 06:15 UTC
Sorry, my English is very poor.
If your first page is "page license", use "PAGE license FunctionNameHere" to defined that page, before "License" page show, NSIS will call Function "FunctionNameHere" first.
And you could put your warning or something inside Function "FunctionNameHere".
Joost Verburg
8th January 2004 14:49 UTC
You should set a language string for all langauge, you haven't got one for Romanian.
The first function called for visible installers is .onGuiInit / Modern UI custom GUIINIT. For silent installers it's the section.
IceRAM
8th January 2004 22:26 UTC
OK.. so, here's how I fixed my script:
I wanted to add some languages to the installer (NSIS default language tables) although I didn't have LangStrings for all, and I got to the next situation:
StrCpy $LSTR_CURRENTUSER "Current User"
StrCmp $(STR_CURRENTUSER) "" +2
StrCpy $LSTR_CURRENTUSER $(STR_CURRENTUSER)
So, in this case, I replaced the use of $(STR_CURRENTUSER) with $LSTR_CURRENTUSER. It isn't really elegant, it isn't elegant at all since I have 16 localized strings (for now).
How could I write a macro that does those comparisons?
I gave it a shot, but it seems I don't handle properly all the variables sent as params. I'd like it to be something like
!insertmacro INIT_STRING $VARIABE $(LANG_STRING) $OTHER_STRING
; the macro would basically assign to VARIABLE the value of LANG_STRING if it's not null or OTHER_STRING otherwise
Is there a way to call the value of $(STR_CURRENTUSER) for a specific language, something like $(STR_CURRENTUSER[$LANG_ID])? (sugestion)
It would be a lot easier for me to call the previous macro like:
!insertmacro INIT_STRING $LSTR_VAR1 $(VAR1) $(VAR1[$LANG_ENGLISH])
10x for your help
p.s. i'll look into moving the code to .onGuiInit
zarged
9th January 2004 12:21 UTC
I used a custom page to allow language specific error messages, just make sure its the first page loaded if your going to check for installer mutex etc, does the following example help?
--- SCRIPT ---
!include "MUI.nsh"
Name "testLangString"
OutFile "testLangString.exe"
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Polish"
!insertmacro MUI_LANGUAGE "Romanian"
!insertmacro MUI_RESERVEFILE_LANGDLL
Page custom LangCheck
LangString VAR1 ${LANG_ENGLISH} "ENGLISH is set"
LangString VAR1 ${LANG_POLISH} "POLISH is set"
LangString VAR1 ${LANG_ROMANIAN} "ROMANIAN is set"
Section dummy
SectionEnd
Function LangCheck
MessageBox MB_OK $(VAR1)
FunctionEnd
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
--- END SCRIPT ---
IceRAM
9th January 2004 22:31 UTC
Nice idea. 10x
I understood how to solve the problem with the initialization of the strings, but I still need to find a fast way of assigning some strings to empty langstring variables. The reason for this is that I want to include with my installer more (NSIS default) languages and, at the same time, use the localized installer strings for some of them.
Joost Verburg
9th January 2004 22:50 UTC
Then you will have to create a macro that sets the default strings.
IceRAM
12th January 2004 15:42 UTC
Is there a way to set the charset when loading a LangString. I have some problems with some Macedonian LangStrings.
The Macedonian NSIS translation looks the same and it has the same charset as the translations I use, but when loaded, the langstrings I use appear using latin1.
Joost Verburg
12th January 2004 15:46 UTC
Do you mean that all standard strings work fine but langauge string not?
IceRAM
12th January 2004 16:05 UTC
Exactly.
Assuming that the charset is wrong, where do I set it?
What charsets are used in LangStrings?
Is it anywhere written what charsets there must be used for specific languages?
(why isn't utf8 used?)
Joost Verburg
12th January 2004 16:25 UTC
UTF8 is not used because it's only supported by Windows 2000/XP. NSIS is designed to work with all major Windows versions.
I've updated the Macedonian language file with a code page (1251), try it again.
IceRAM
12th January 2004 21:54 UTC
Comment: The NSIS default installer strings looked great (in case you have changed the default lang file, please undo - it looked great before - or... it might look great now too, but... does it change in any way what charset I use for modifying own LangStrings?).
The LangStrings I define appear in the wrong way and I can't alter(define) the charset - I don't even know what charset is.
My problem shortly: what charset should I use for the Macedonian LangStrings so that display correctly, just like the NSIS translation?
Is the charset different for each language? If yes, where are the charset assignments for each language defined?
Joost Verburg
12th January 2004 22:05 UTC
As I said in my previous post, there was no code page defined in the Macedonian language file.
I have now added the code page, please try whether that solves your problem.
IceRAM
13th January 2004 20:47 UTC
Hmm.. the problem is that, using the latest nightly build, my installer looks horrible. The text is converted to RightToLeft, no language is auto-detected on start (the dropdown is empty, it had English autoselected before).
I still have to figure out why it's not working. Trying previous versions with the current translation.
IceRAM
13th January 2004 21:04 UTC
My mistake. Still testing. I'll have some feedback regarding the latest changes in the translation shortly.
It seems that the compiler does not work properly (the output executable is corrupted - segfaults, no default language selected etc.) when an AntiVirus monitor is running in background - maybe a warning could be put somewhere to prevent this.
Joost Verburg
13th January 2004 21:19 UTC
We have never had any reports of incompatibilities with anti-virus software. I think corrupted compilations can never be the result of such software.
Make sure you are doing nothing else wrong and attach your script.
IceRAM
13th January 2004 21:22 UTC
Found a strange behaviour when loading languages.
I have to mention that I used NSISrc2 with the new Macedonian language updates.
This is part of my installer script:
!insertmacro UI_LANGUAGE_LOAD "English"
!insertmacro UI_LANGUAGE_LOAD "Dutch"
!insertmacro UI_LANGUAGE_LOAD "Macedonian"
; !insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "SimpChinese"
If I leave it as you see it, the installer crashes when it loads (Windows displays that dialog containing "Would you like to Debug....").
If I uncomment French, it works ok. I don't know why. Maybe the language files have something in them that does not work properly.
Still didn't check if the Macedonian LangStrings look ok.
Note: UI_LANGUAGE_LOAD is a macro that loads MUI_LANGUAGE and the LangStrings for a specific language (availaible on the NSIS site archive).
Joost Verburg
13th January 2004 21:25 UTC
Can you create a script that reproduces this error and does not need any external files or macros?
IceRAM
13th January 2004 21:34 UTC
Indeed.. it might not have to do anything with the antivirus (probably a coincidence: I turned it off and, at the same time, commented some languages to make it "lighter")
Trying to isolate the problem in a small script.
eccles
13th January 2004 21:36 UTC
I've just reproduced this by using the same combination of languages in the Examples\Mordern UI\MultiLanguage.nsi example. I'm looking into it right away...
Thanks.
IceRAM
13th January 2004 22:13 UTC
The Macedonian Strings look ok now. 10x for fixing it.
Regarding the crashes, I wrote a separate post.
10x for your support.