You are here

Problem with Installer Language Code

9 posts / 0 new
Last post
Patrick Patience
Offline
Last seen: 4 years 3 months ago
DeveloperModerator
Joined: 2007-02-20 19:26
Problem with Installer Language Code

While using the installer code from Toucan for one of my latest apps in beta, BonkEnc Portable I'm trying to change the way the installer writes the language of the actual application to it's settings depending on the language chosen from the installer, I'm having trouble, and would appreciate some help.

This is the code from Toucan I'm changing

;=== Set Language
StrCmp $LANGUAGE "1031" 0 +3 ;German
WriteINIStr $INSTDIR\Data\Settings.ini "General" "Language" "wxLANGUAGE_GERMAN"
Goto RefreshPortableAppsMenu
StrCmp $LANGUAGE "1036" 0 +3 ;French
WriteINIStr $INSTDIR\Data\Settings.ini "General" "Language" "wxLANGUAGE_FRENCH"
Goto RefreshPortableAppsMenu
WriteINIStr $INSTDIR\Data\Settings.ini "General" "Language" "wxLANGUAGE_ENGLISH" ;=== Fallback to English

And this is what I changed the above code to for my app, since my app uses an XML file to store settings, not an INI. I decided just to have the installer replace the language string in the default settings instead of adding in some code that would require XML plugins.

;=== Set Language
StrCmp $LANGUAGE "1031" 0 +3 ;German
${ReplaceInFile} "$INSTDIR\App\DefaultData\settings\config.xml" "internal" "bonkenc_de.xml"
Delete "$INSTDIR\App\DefaultData\settings\config.xml.old"
Goto RefreshPortableAppsMenu
StrCmp $LANGUAGE "1036" 0 +3 ;French
${ReplaceInFile} "$INSTDIR\App\DefaultData\settings\config.xml" "internal" "bonkenc_fr.xml"
Delete "$INSTDIR\App\DefaultData\settings\config.xml.old"
Goto RefreshPortableAppsMenu
${ReplaceInFile} "$INSTDIR\App\DefaultData\settings\config.xml" "internal" "internal"
Delete "$INSTDIR\App\DefaultData\settings\config.xml.old" ;=== Fallback to English

Now, I understand from other parts of the installer that the numbers are variables for languages. So if it's using 1031 language, it will use the lines below it. Does the installer skip the any code that is not the variable of the language it's using and then just default to English? I think it does. The problem I have is when I compile, it compiles fine, but then I get an error saying 'Installer Corrupter: Invalid opcode'. So I'm wondering what I have to change, and what the 0 +3 thing means.

I tried reading into this, but I just can't figure it out. I know this is mainly a question for Johns since he wrote it, and I'd love some quick help.

I know it's probably something with the fact that it's StrCmp and I'm using ReplaceInFile, but I don't know what.
Thanks.

rab040ma
Offline
Last seen: 1 day 14 hours ago
Joined: 2007-08-27 13:35
+3 <=== "jump if not equal"

The +3 means to skip ahead 3 lines (if not equal). That takes program flow to the next StrCmp. (Careful how you count. You're going to the third line, not skipping over three intervening lines.)

It might be clearer to use a label instead.

You probably want it to skip ahead a different number of lines (like +5 to get to the next StrCmp) ... or put in a label and have it jump to the label instead.

The 0 means to go to the next line. So if the things are equal, you go to the next line; if they are not equal, you skip to a different section.

MC

Patrick Patience
Offline
Last seen: 4 years 3 months ago
DeveloperModerator
Joined: 2007-02-20 19:26
Thank you SO Much

I'll try that.

I hope John's emailed you about becoming an official dev, although he is really opening to outside dev's now. As I've noticed you know a lot about NSIS. Smile

rab040ma
Offline
Last seen: 1 day 14 hours ago
Joined: 2007-08-27 13:35
Why thank you. So far I

Why thank you.

So far I haven't found something to work on; the obvious ones seem to be taken.

MC

Patrick Patience
Offline
Last seen: 4 years 3 months ago
DeveloperModerator
Joined: 2007-02-20 19:26
Tried it

I tried it. I changed it to 4 at first, because the lines above are wrapped, and it all stayed english, so I changed just the first one to 5 and the german and english worked, then I change both to 5 and nothing worked, so I'll just use labels. Smile

Edit: Labels work fine, thanks.

Thanks.

sag47
Offline
Last seen: 10 years 2 months ago
Joined: 2007-11-17 16:19
This also would have

This also would have worked:

 ;=== Set Language
StrCmp $LANGUAGE "1031" 0 +4 ;German
${ReplaceInFile} "$INSTDIR\App\DefaultData\settings\config.xml" "internal" "bonkenc_de.xml"
Delete "$INSTDIR\App\DefaultData\settings\config.xml.old"
Goto RefreshPortableAppsMenu
StrCmp $LANGUAGE "1036" 0 +4 ;French
${ReplaceInFile} "$INSTDIR\App\DefaultData\settings\config.xml" "internal" "bonkenc_fr.xml"
Delete "$INSTDIR\App\DefaultData\settings\config.xml.old"
Goto RefreshPortableAppsMenu
${ReplaceInFile} "$INSTDIR\App\DefaultData\settings\config.xml" "internal" "internal"
Delete "$INSTDIR\App\DefaultData\settings\config.xml.old" ;=== Fallback to English

Macro lines and defined lines count as lines of code within sections and functions

What's a signature?

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 14 years 6 months ago
Joined: 2006-01-06 21:27
But...

It's more readable to use labels anyway.

"If you're not part of the solution, you're part of the precipitate."

Lurking_Biohazard
Lurking_Biohazard's picture
Offline
Last seen: 5 years 7 months ago
Joined: 2006-02-18 18:06
Project

How about Halite?
It has been mentioned a few times, but I don't think anyone has done it.
Just a thought...

~Lurk~

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 14 years 6 months ago
Joined: 2006-01-06 21:27
Yoink!

*steals*

"If you're not part of the solution, you're part of the precipitate."

Log in or register to post comments