switchLang()

Function for switching the language at runtime in a user interface.

Synopsis

int switchLang(int langIdx | OaLanguage lang | string lang);

Parameters

Parameter Description
langIdx Index of the language that is switched to during runtime in the user interface.
lang (OaLanguage) Language, which can be switched at runtime in the user interface, given as OA language enum.
lang (string) Language, which can be switched at runtime in the user interface, given as a string.

Return value

In the event of an error -1, otherwise 0.

Errors

Missing or incorrect parameters.

Description

Via this function, the language in a user interface can be changed at runtime (the language is changed for all modules and panels that were opened with the user interface manager). The languages, which can be switched, must be defined when creating the project (e.g. a multilingual project with "de_AT.utf8" and "en_US.utf8").

When using changeLang() or switchLang(), the Initialize script of the panel is executed again. For more detailed information on this behavior see the chapter Online language switching.

If the function switchLang() is used in a CTRL script, this script is aborted immediately after initialization of the panel (last command == switchLang()).

Switching of the user interface into German. Assign the following script to the "Clicked" event of a button:

main()
{
  int lang;
  lang = getLangIdx("de_AT.utf8");
  switchLang(lang);
}

Assignment

Multilingual functionality

Availability

UI