LabVIEW Internationalization using Unicode

Internationalizing your software can involve, among other things, converting your user interface strings into languages that use other scripts. The preferred method for doing this, Unicode, can be problematic in LabVIEW because of limited, sometimes buggy, support in the language. There is an NI white paper on the topic that you should look at first to understand the fundamental issues: LabVIEW Unicode Programming Tools.

The UString subpalette has been added to the MGI Library String palette.

The UString subpalette has been added to the MGI Library String palette.

MGI is releasing an addition to the MGI Library, UStrings, that is similar in approach to the NI tools, but makes some improvements that should reduce opportunities for bugs in your code. In the NI version, string wires can contain Unicode or non-Unicode, and a separate Boolean wire tells which interpretation to use. The main thing that MGI adds is a UString class that encapsulates the string and Boolean data. As a result, there are only a few places exposed where a string wire with the wrong sort of data can be connected.

In this simple example, there are no string wires, just array and scalar UStrings.

A translation table is used to update the caption of a numeric indicator.

A translation table is used to update the caption of a numeric indicator.

The primary decision in using UStrings is how you’d like to store your Unicode data. MGI has left that fully up to the user by providing 8 different constructor methods and a VI template for constants. If you look at the example MGI Various Controls with UStrings.vi, along with seeing many different uses of UStrings, you’ll also see a variety of ways of constructing them.

The example MGI Various Controls with UStrings.vi demonstrates 4 of the UString constructor VIs and use of the constant template.

The example MGI Various Controls with UStrings.vi demonstrates 4 of the UString constructor VIs and use of the constant template.

One of the other constructors is specifically designed for parsing translation tables stored in a file rather than hard coded. A spreadsheet could then be used to maintain the translations, and new languages could be supported without recompiling code.

MGI 2DUString(BOM+Unicode, Delims).vi is a constructor that can parse a Unicode tab delimited spreadsheet string containing a translation table.

The block diagram of MGI 2DUString(BOM+Unicode, Delims).vi. This VI is a constructor that can parse a Unicode tab delimited spreadsheet string containing a translation table.

To start using UStrings to translate your front panels:

  1. Look over the NI White Paper if you have not already done so.
  2. As described, add the line “UseUnicode=True” to your LabVIEW.ini file.
  3. Update to the latest version of the MGI String package using VI Package Manager. (The package isn’t released yet, so download it here for now.)
  4. Look through the examples to see how to translate specific UI elements.
  5. Work out the best way to store Unicode strings for your particular application.
  6. Profit!