Set the project’s language during run time
You can set your project’s language during run time by using the function SetLanguage anywhere that an expression can be configured.
Before you begin this task, you must have already added at least one target language to the Translation Table worksheet. For more information, see Add a target language to the Translation Table.
The function SetLanguage takes one parameter: the Locale ID for the target language. The Locale ID for a language is shown in parentheses next to the language in the Translation Table worksheet — for example, “English-United States” is 1033.
The following example shows how to draw two Button objects that switch the project’s language between English and French:
- In the Graphics tab of the Project Explorer, double-click a project screen to open it for editing.
- On the Graphics tab of the ribbon, in the Active Objects group, click Button.
- Draw a Button object in the project screen.
- Double-click the Button object. The Object Properties dialog is displayed.
- In the Caption box, type English.
- Click Command. The Command animation properties are displayed in the dialog.
- In the first row of the On Down tab, in the Expression field, type SetLanguage(1033).
- Close the Object Properties dialog.
- Duplicate the Button object, either by copy-and-paste or by Ctrl+Click.
- Repeat steps 4 through 8, replacing the caption with French and the expression with SetLanguage(1036).
- Save and close the project screen.
You can directly set the language of the Virtual Keyboard, separate from the project’s language, by calling the function SetKeyboardLanguage during run time.