Published January 30, 2015
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.
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.
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.
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.
- Look over the NI White Paper if you have not already done so.
- As described, add the line
UseUnicode=Trueto your LabVIEW.ini file.
- Update to the latest version of the MGI String package using VI Package Manager.
- Look through the examples to see how to translate specific UI elements.
- Work out the best way to store Unicode strings for your particular application.