Methods on gw.api.util.LocaleUtil

In addition to runAsCurrentLanguage, runAsCurrentLocaleAndLanguage, and runAsCurrentLocale, the class gw.api.util.LocaleUtil provides a number of other methods useful in working with localization, including the following:

Method

Description

canSwitchLanguage

Returns boolean true if the current user is assigned to a role that has the usereditlang permission, which allows the user to switch to a different language.

canSwitchLocale

Returns boolean true if the current user is assigned to a role that has the usereditlang permission, which allows the user to switch to a different locale.

getAllLanguages

Returns a list of the typecodes of all languages defined in the LanguageType typelist.

getAllLocales

Returns a list of the typecodes of all locales defined in the LocaleType typelist.

getCurrentLanguage

Returns the effective language for the thread as a GWLanguage object. This language can be, in order of priority, the temporary setting, such as by runAsCurrentLanguage, the user setting, or the system setting.

getCurrentLocale

Returns the effective locale for the thread as a GWLocale object. This locale can be, in order of priority, the temporary setting, such as by runAsCurrentLocale, the user setting, or the system setting.

getCurrentLanguageType

Calls getCurrentLanguage and returns a LanguageType typecode.

getCurrentLocaleType

Calls getCurrentLocale and returns a LocaleType typecode.

getDefaultLanguage

The system setting for the language, set in configuration parameter DefaultApplicationLanguage.

getDefaultLocale

The system setting for the locale, set in configuration parameter DefaultApplicationLocale.

getLanguageLabel

Returns the localized display name for the language as a String. For example, if the current language is English and the method parameter is LanguageType.TC_DE_DE, the method returns "German". However, if the current language is German, the method returns "Deutsch".

getLocaleLabel

Returns the localized display name for the locale as a String. For example, if the current language is English and the method parameter is LocaleType.TC_DE_DE, the method returns "German (Germany)". However, if the current language is German, the method returns "Deutsch (Deutschland)".

toLanguage

Converts a LanguageType typekey to a GWLanguage object and returns it as an ILocale object.

toLocale

Converts a LocaleType typekey to a GWLocale object and returns it as an ILocale object.