Change the language at runtime

  • November 30, 2011
  • 0 Comments

Normally when you change your language you go to your user options, change your current language and the restart the client. This week I got the question if it was possible to do so in runtime. You can do so by just calling the infolog.language(str 7 _languageCode). All labels that you load after calling this method will be translated to the new language.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
static void JDO_ChangeLanguage(Args _args)
{
info("@SYS1");
infolog.language('nl-be'); // Change the language to nl-be
info("@SYS1");
infolog.language('fr-be'); // Change the language to fr-be
info("@SYS1");
infolog.language('it'); // Change the language to it
info("@SYS1");
infolog.language('de'); // Change the language to de
info("@SYS1");
infolog.language('en-us'); // Change the language to en-us
info("@SYS1");
}

And the result is:

Caution: When you use this function make sure you get the current language before you use this function, so you can change it back when you don’t need it any more.