Sets the language to display literals in your application.
Name (not the description) of a Language in your Knowledge Base to be used for the translation.
Objects: Procedure, Transaction, Web Panel, Panel, Data Provider
Generators: .NET, .NET Framework, Java, Apple, Android, Angular
The SetLanguage function returns 0 if the Language can be changed. Otherwise, it returns a non-zero value. If the specified language cannot be loaded, then no language change is performed and the current language remains as if the method had not been executed. Once the SetLanguage function has been executed successfully, the Language setting remains active for the rest of the session. In Web applications, this means that the GeneXus code automatically saves the value of the current language in the current session.
- For Web applications: In order to refresh all the texts and language dependant elements of the web page, a refresh command should be added after the call to SetLanguage function. This refresh command will make a GET of the web page, a different behavior than if the command is not used after a SetLanguage function (check SAC #24129). Remember that making a GET of the web page implies that values entered in editable fields will be lost.
Browsers running GeneXus applications using Design Systems require support for the 'dir' attribute (HTML attribute: dir, CSS Logical Properties). Check SAC #52783.
- For Mobile applications: This function is available from GeneXus X Evolution 3 Upgrade 9 and higher. It's recommendable to use GoHome Method after changing the language in order to "refresh" the previously loaded panels. For it to work set the environment's property "Translation type" to "Run-time".
- For Evo2, .NET: SetLanguage(&MyLanguage) does not always work, but SetLanguage(!'Spanish') or SetLanguage(!'English) does. So use a literal instead of variables if you have troubles with the sample code below.
: Remember to set Translation type property
to "run-time" in order to change the language in runtime and to enable the need language objects in the KB. Otherwise a non-zero value will be returned when the function is used. If Android is used messages like: "set Language to : LanguageId" / "set Language failed. Language LanguageId not found in catalog." appears when debugging (monitor.bat)
&NumericVariable = SetLanguage(!"Spanish")
GeneXus Application Localization