You can create localized Windows Installer packages using WiX by defining single product sources, but with multiple localization files, or .wxl files.
Because Windows Installer packages themselves are not localizable for the most part, you need to build multiple packages. But maintaining multiple sources can be difficult and error prone. WiX allows you to define single sources but to use binder variables for localized fields, or localization variables. In the example below, you'll see these expressions as !(loc.variableName).
<?xml version="1.0" encoding="utf-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Id="!(loc.ProductCode)" Name="!(loc.ProductName)" Language="!(loc.ProductLanguage)" Version="1.0.0.0" Manufacturer="Northwind" UpgradeCode="!(loc.UpgradeCode)"> <Package Languages="!(loc.ProductLanguage)" Description="!(loc.Description)" Comments="!(loc.Description)" InstallerVersion="200" Compressed="yes" SummaryCodepage="!(loc.CodePage)" /> <Media Id="1" Cabinet="product.cab" /> <Feature Id="MyFeature" Level="1" Description="!(loc.MyFeatureDescription)"> <ComponentRef Id="MyComponent" /> </Feature> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="LocalizedDir" Name="!(loc.ProductLanguage)" ComponentGuidGenerationSeed="8987128B-1430-4AC9-81F2-C51B60A3084C"> <!-- Assign auto-generated GUID --> <Component Id="MyComponent" Guid="*" DiskId="1"> <File Id="Example.txt" Name="Example.txt" Source="!(loc.ProductLanguage)\Example.txt" KeyPath="yes" /> </Component> </Directory> </Directory> </Product> </Wix>
Author 1033\Example.txt with an example string, then compile your sources to a location to be linked and localized later.
candle.exe example.wxs -out example.wixobj
Once the package is compiled, you can link the .wixobj multiple times with different .wxl files. But first you must define your .wxl file, which is just a collection of strings.
<?xml version="1.0" encoding="utf-8"?> <WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization"> <String Id="CodePage" Localizable="no">Windows-1252</String> <String Id="Description">Installs the Localization Example</String> <String Id="MyFeatureDescription">Example Feature</String> <String Id="ProductCode" Localizable="no">{000C1109-1033-0000-D000-000000000046}</String> <String Id="ProductLanguage" Localizable="no">1033</String> <String Id="ProductName">Localization Example</String> <String Id="UpgradeCode" Localizable="no">{84108EA9-1033-4A62-9BB4-7093DD4CDC89}</String> </WixLocalization>
Define separate .wxl files like en-us.wxl shown above for each language you will support. Be sure to set the WixLocalization/@Culture attribute to different culture names.
Now link and localize your package to a culture-specific directory.
mkdir en-us light.exe example.wixobj -cultures:en-us -loc en-us.wxl -out 1033\example.msi
The -cultures switch is used to pick resources in extensions like the WixUIExtension.
You can build localized packages using WiX by compiling a single set of sources and linking to separate packages using different localized files. This makes maintaining sources for localized packages easier and less prone to inconsistencies.