Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i have an installer for my application which is built using Inno Setup.
I want to support multiple languages using the installer to allow the user to choose the language.

My app uses a lot of common files for any language, but for some files - such as the string resources, help files, etc - there will be these files for each language.

I want the installer to contain all these files. Then when the user has selected a language, it will install whatever it needs and then somehow only install the language specific files. The destination for these files will always be the same, but the source files that get copied will be different (i.e. depending on the language). I do not know how to do this.

I found out that i can set ShowLanguageDialog to show a page in installation that lets you choose the language. And i know you can set the installer's language in the [Language] section. So that's one step done.

Now all i need to do is somehow conditionally install files based on the selected language. So for, say, help files, the installer will contain the files for all languages that my app is translated in. These will be in source folders named after the lang id (e.g. Polish is \pl_PL\help). But the installer should just install it to a help directory in the program folders directory.

One other way i could do this is to install in different destination directories based on what language is selected (in Inno, i can use {language}).
So, for example, if Polish is selected, the help files will be installed in "(MyAppsInstallDir)\help\pl_PL\the files.html".
But the problem with this is that i need to write additional code in my app to find those files, which just adds unnecessary complexity.
Posted

1 solution

You do it by first creating/amending the [Languages] section, using the appropriate ISL files:

[Languages]
Name: en; MessagesFile: "compiler:Default.isl"
Name: nl; MessagesFile: "compiler:Languages\Dutch.isl"


Then all you have to do is add a "Languages" parameter to the items in the [Files] section:

[Files]
Source: "Help.chm"; DestDir: "{app}"; Languages: en
Source: "Dutch\Help.chm"; DestDir: "{app}"; Languages: nl

-- An item with a "Languages" tag will only be installed if the user has chosen that language for the installation.

-- Any item in that does not have a "Languages" tag will be installed every time.
 
Share this answer
 
v2
Comments
XTAL256 4-Dec-10 4:19am    
Awesome, thank you very much! I didn't know about that "Languages" tag, i only knew that you can use the {language} variable in the source or destination directory.
I was expecting to have to do some very ugly code to conditionally install files using some script or something. Turns out Inno has a very elegant solution. Just another reason to like Inno (much better than InstallShield, which i have also worked with)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900