Setting a language for a block of Gosu code
You can set a specific language in any Gosu code block by wrapping the Gosu code in any of the following methods.
// First method - Sets language only
gw.api.util.LocaleUtil.runAsCurrentLanguage(alternateLanguage, \ -> { code } )
// Second method - Sets both language and region
gw.api.util.LocaleUtil.runAsCurrentLocaleAndLanguage(alternateLocale, alternateLanguage, \ -> { code } )
Note: The second method sets both region and language at the same time. This
topic covers setting the language only.
A typical use of this feature is to override the current language that the Gosu code block uses by default. The default current language is specified by the current user or the DefaultApplicationLanguage parameter in config.xml. If neither is set, PolicyCenter uses the browser language setting.
Method parameters
The two listed methods use some, or all, of the following parameters.
alternateLocale- An object of type
ILocalethat represents a regional format from theLocaleTypetypelist. Specify a GWLocale object for this parameter. alternateLanguage- An object of type
ILocalethat represents a language from theLanguageTypetypelist. Specify a GWLanguage object for this parameter. \ -> { code }- A Gosu block as a GWRunnable object—the Gosu code to run in a different locale or language.
