MSI Factory 2.3

How To: Support Multiple Languages from One Installer

How To: Support Multiple Languages from One Installer

Previous topic Next topic  

How To: Support Multiple Languages from One Installer

Previous topic Next topic  

MSI Factory

Although each MSI file can only contain a single language, it is possible to make an installer that supports multiple languages from one installation package using a combination of MSI transforms and a custom bootstrapper. Below is a general description of how to accomplish this:

1. Include multiple languages in your MSI Factory project.

- Select Project > Languages from the menu.

- Add as many languages as you want to support from your installer. See the appropriate section in the help file for more details about using the Languages dialog.

2. Build one version of your installer for each language.

- Select Build > Build Installer from the menu and select a language. You will need to build one .MSI file for each language. Make sure that you rename the .MSI file after each build or else go into Build > Settings and change the output filename before each build. So, for example, generate "productx-ENU.msi", "Productx-DE.MSI", etc.

- Although building all of these installers seems to contradict the goal of this exercise, you will see why it is done in the next step.

3. Generate transform files for each language.

A transform file is a file that basically contains the differences between two Windows Installer package (.MSI) files. It has the file extension .MST. These transform files can then be applied to a Windows Installer package when run as you will see later.

What we need to do in this step is:

a) Pick one of your MSI packages as your "baseline" or "default" packages. This will probably be the one that uses the language most common to your users.

b) Make a transform file for every OTHER language against the baseline language chosen in (a) above.

The easiest way to do this is to use the free tool that ships with MSI Factory. It is in MSI Factory's installation folder and has the name "IRMakeMSITransform.exe". It is a command line tool here is the usage:

IRMakeMSITransform.exe <NewMSI> <OrigMSI> <Transform> [/E:<Flags>] [/V:<Flags>]

<NewMSI> (Required) The new Windows Installer database file (the "target").

<OrigMSI> (Required) The original Windows Installer database file (the "baseline").

<Transform> (Required) The transform filename to output to. Usually has ".mst" file extension.

/E:<Flags> (Optional) The error conditions that should be suppressed when the transform is applied. This should be a number made up of a bit mask. See the iErrorConditions value in the MsiCreateTransformSummaryInfo help topic in the Microsoft Platform SDK for details about valid values.

/V:<Flags> (Optional) Specifies the properties to be validated to verify that the transform can be applied to the database. This should be a number made up of a bit mask. See the iValidation value in the MsiCreateTransformSummaryInfo help topic in the Microsoft Platform SDK for details about valid values.

 

So, for example, let's say that we have three languages that we want to support for which we have generated 3 MSI files: "setup-english.msi", "setup-german.msi" and "setup-french.msi" where "setup-english.msi" is our baseline installer. We will want to run this application 2 times:

IRMakeMSITransform.exe "c:\Setups\setup-german.msi" "c:\Setups\setup-english.msi" "c:\Setups\german.mst"

IRMakeMSITransform.exe "c:\Setups\setup-french.msi" "c:\Setups\setup-english.msi" "c:\Setups\french.mst"

 

We will now have three files that we will be distributing: "c:\Setups\setup-english.msi", "c:\Setups\german.mst" and "c:\Setups\french.mst". The other MSI files are no longer needed. They were only necessary in order to generate the transform files.

Technically, you do not need to go onto step 4 unless you want the convenience of a single file distribution for your setup. You can run your installer right now, as it is, and apply a transform. For example:

msiexec.exe -i "c:\Setups\setup-english.msi" - This will run the installer with the English text.

msiexec.exe -i "c:\Setups\setup-english.msi" TRANSFORMS="c:\Setups\german.mst" - This will run the installer with the German text.

msiexec.exe -i "c:\Setups\setup-english.msi" TRANSFORMS="c:\Setups\french.mst" - This will run the installer with the French text.

4. Integrate the files into your custom bootstrapper script. (optional)

You will need to create a custom bootstrapper for your installer using the Indigo Rose Bootstrapper Designer application that ships with MSI Factory. You can start it by choosing Tools > Bootstrapper Designer from MSI Factory's menu.

What you will generally need to do is:

a) Go to the Files tab and include your MSI and MST files.

b) Create a Lua script that will run and then extract and run the appropriate installer with the appropriate command line options. Here is a sample script that is incomplete, but demonstrates the kind of logic that will need to be used:

-- START OF CODE SAMPLE

local strLanguage = Dialog.ComboBox("Choose Language",

                                   "Select an installation language:",

                                   {"English","German", "French"}, "English",

                                   true, false, MB_ICONQUESTION);

 

local strTransformCommandLine = "";

local strExtractFolder = _TempFolder.."\\Installer\\";

 

if(strLanguage ~= "CANCEL")then

   if(strLanguage == "German")then

       local strGermanFile = strExtractFolder.."german.mst";

       Archive.ExtractFile("german",strGermanFile);

       strTransformCommandLine = "TRANSFORMS=\""..strGermanFile.."\"";

   end

 

   if(strLanguage == "French")then

       local strFrenchFile = strExtractFolder.."french.mst";

       Archive.ExtractFile("french",strFrenchFile);

       strTransformCommandLine = "TRANSFORMS=\""..strFrenchFile.."\"";

   end

end

 

local strInstallerExtract = strExtractFolder.."setup-english.msi";

Archive.ExtractFile("setup-english",strInstallerExtract);

local strCommandLine = "-i \""..strInstallerExtract.."\"";

 

if (strTransformCommandLine ~= "") then

   strCommandLine = strCommandLine.." "..strTransformCommandLine;

end

 

MSI.RunMsiexec(strCommandLine);

-- END OF CODE SAMPLE

One interesting thing to note is that when you run a Windows Installer package with a transform, the transform file will be cached on the system. It will then be used when the installer is run on the system in repair or remove mode without having to do anything differently.

It is a bit of an involved process to make all of this happen, but MSI Factory allows you the flexibility and control to make it happen. Using the instructions and guidelines above, you can support multiple installer languages without the overhead of multiple installer packages.


Learn More: Indigo Rose Software - MSI Factory - Buy Now - Contact Us