Category Archives: WiX

L10N/M10N: Localization minimization

Localized strings in setup, especially setup UI, tend to be full of flowery and marketing-driven language. They’re distasteful to type once, much less many times. You might have tried to use preprocessor variables in your WiX localization strings, like this:

<String Id="ProductLongName">$(var.ProductShortName)(R) $(var.ProductMarketingVersion)</String>

Then you discover that your product is now named “$(var.ProductShortName)(R) $(var.ProductMarketingVersion).” The reason for that is simple, if not obvious: $(var) references are handled by the WiX preprocessor, which happens before compilation, as part of Candle.exe. Localization strings are handled at bind time by Light.exe. The compiler and preprocessor are nowhere to be found.

One solution is to simply repeat yourself. It makes for straightforward localization strings but it means that some changes have to be reflected in multiple localization strings. For example, version numbers frequently show up in multiple strings.

Luckily, it doesn’t have to come to that. Though not explicitly documented (quelle surprise!), localization strings can contain references to other localization strings. For example, the following strings are legal:

<String Id="ProductShortName">BobStudio</String>
<String Id="ProductMarketingVersion">2013 Update 2</String>
<String Id="ProductLongName">!(loc.ProductShortName)(R) !(loc.ProductMarketingVersion)</String>

When used in authoring:

<Product Name="!(loc.ProductLongName)" ...

the resulting ProductName property is, exactly as you’d expect:

BobStudio(R) 2013 Update 2

The code in WiX responsible for this behavior is WixVariableResolver. As the name implies, it’s not limited to just localization variables, but also works for other bind-time variables. For example, you can also use the special !(bind) variables:

<String Id="ProductLongName">!(loc.ProductShortName)(R) !(loc.ProductMarketingVersion) [!(bind.fileVersion.App.exe)]</String>

yields

BobStudio(R) 2013 Update 2 [3.7.1224.0]

WiX v3.6 is released

After just under two and a half years in development, WiX v3.6 has been released. Actually, it’s been in development for longer than that, counting work Fredrik, Rob, and I did in Burn before v3.6 began. And now it’s out for everyone.

The Codeplex download page has the release notes I wrote to summarize the changes since WiX v3.5. I’ve blogged about some of the other changes as they developed but even I was surprised at the number of changes and additions other than Burn. (Thanks to Beyond Compare for helping weed out insignificant diffs.)

According to the good ol’ SourceForge bug tracker, 688 bugs were opened and targeted for WiX v3.6; of those, 493 were fixed. Though a few were postponed, WiX v3.7 has only 25 bugs at the moment.

I, for one, will take the rest of Labor Day off. Then tomorrow it’s back to WiX v3.7!

Localizing more than strings in WiX v3.6

Localizing an MSI package—primarily the user interface but also bits like the product name, shortcut names, and other user-visible, localizable strings—has been pretty much unchanged since WiX v2.0:

  • Localizable strings are specified in the appropriate attributes in your WiX authoring using !(loc.stringid) syntax.
  • Strings are specified by id in per-language WixLocalization (.wxl) files.
  • Light, the WiX linker, takes a list of cultures to use when resolving !(loc.stringid) in the authoring.

As you can see, localization is all about the strings. However, strings can vary dramatically in length among languages. In the WixUI dialog library, controls were sized to handle string lengths for all the languages WixUI supported. Unfortunately, that resulted in some controls being far wider than necessary. The Install button, for example, is wider than the other buttons on the same dialogs. We hadn’t had to resize any controls in WixUI for a while—and then a bug said otherwise.

Rather than yet again resizing a control, WiX v3.6 gets a new feature so we never have to do that again. In WiX v3.6, the WixLocalization schema has been extended with a UI child element that lets the localization for a particular culture change the attributes of an individual control or an entire dialog. For example, a later bug indicated the need for another big button in WixUI_Advanced. The fix in the ru-RU localization file was easy:

<UI Dialog="AdvancedWelcomeEulaDlg" Control="Print" X="50" />
<UI Dialog="AdvancedWelcomeEulaDlg" Control="Advanced" X="124" Width="85" />

The first line moves the Print button to the left, to make room for a bigger Advanced button, which the second button supplies. The dialog and control attributes identify a particular control.

The WixLocalization UI element (unrelated to the UI element in the WiX namespace) lets you:

  • Resize a control using the Height and Width attributes.
  • Move a control using the X and Y attributes.
  • Change the control’s localization-related attributes: LeftScroll, RightAligned, and RightToLeft.
  • Change the control’s text using the inner text of the UI element.

You can also use the UI element on dialogs by omitting a Control attribute:

  • Resize a dialog using the Height and Width attributes.
  • Change the dialog’s centering values using the X and Y attributes.
  • Change the dialog’s title using the inner text of the UI element.

Don’t forget native code

Though localization files are most often used inside MSI packages using WixUI dialog sets, they’re also used extensively in the WixStandardBootstrapperApplication for Burn. And even if you use a managed bootstrapper application, you’re still using WixStandardBootstrapperApplication when the managed host needs to install .NET.

 

WiX v3.6 RC0 is now available

As Rob announces, the RC0 build of WiX v3.6 is now available. Though traditionally “release candidate” means that the build is one that’s potentially shippable, we know we’re not quite done yet. There are bugs we still intend to fix and the potential for more. That potential is the bugs you find and file, so go download, rebuild your packages and bundles, and make sure WiX v3.6 is the best release of WiX yet.