To localize strings for objects that display at run time, such as dialog boxes, add custom entries to a string dictionary file and use the
Get Localized String
node to retrieve the strings programmatically.
Before you can localize objects that display at run time, generate a string dictionary file using
Export strings, create a copy of the string dictionary file, and save it in a new folder that indicates the language of the string dictionary file. You must save the new folder within the project folder in the same location as the original dictionary folder and name the new folder using standard Microsoft locale names, such as en-US or zh-CN.
Export strings
overwrites any existing dictionary in the folder for the default language of the editor. If you want to preserve an existing dictionary, save a copy of the existing dictionary file in a separate location. You can also create your own string dictionary file which contains entries for each string you want to localize, but this file must follow the same syntax and file extension as the dictionaries that
Export strings
generates.
Note
You do not need to use custom dictionary entries to localize most objects in an application, such as object labels and descriptions. To localize these types of objects, refer to
Exporting Strings for Localization.
Complete the following steps to localize strings that display at run time.
-
Open the string dictionary file you want to edit with a text editor.
-
Add a key to the string dictionary file. You can specify any name for the key, but any new entries you add to the dictionary file must use the same syntax as the entries automatically generated by
Export strings.
-
Add the localized text you want the object to display within the
<loc>
element. If you want to localize the text "Good Morning!" to German, for example, make your new entry look similar to the following example:
<entry key="New_Key_Name">
<loc>[de-DE] Guten Morgen!</loc>
</entry>
Repeat this process for each string you want to localize.
-
Save the dictionary file.
-
Add the
Get Localized String
node to the diagram.
-
Right-click the
key
input and select
Create constant. Enter the key name you added to the dictionary file. For the above example, enter
New_Key_Name.
-
Right-click the
fallback
input and select
Create constant. Enter text in this constant that you want to display if the
Get Localized String
node cannot locate the key you specify in
key.
-
Right-click the
base path
input and enter the file path to the application you want to localize.
-
Wire the
localized string
output to the object you want to localize. For example, if you want to localize the string in a dialog box, wire this output to the
message
input of a dialog box node.
-
Run the application.
The application now displays the localized string(s).
Note
The application determines which dictionary to retrieve keys from based on the language you define in the editor preferences. You must have the editor set to the desired language, or the application does not display the localized strings.
You have now created a localized string dictionary for your code. If you created a library, consider
optimizing its performance
before
packaging your library. If you created an application,
build it into an executable.