Package com.hybris.cockpitng.i18n
Interface CockpitLocaleService
-
- All Known Implementing Classes:
DefaultCockpitLocaleService
public interface CockpitLocaleServiceManages Locale for a cockpit application. The currently set locale is used for label localization on the cockpit (UI) side.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <T> TexecuteWithLocale(AbstractExecutionBody<T> executionBody, java.util.Locale locale)Using this method you can execute code in a context of a different locale than the current onejava.util.List<java.util.Locale>getAllLocales()Returns a list of all available locales.default java.util.List<java.util.Locale>getAllUILocales()Returns a list of all available locales.java.util.List<java.util.Locale>getAvailableDataLocales(java.lang.String principal)Returns a collection of available data locales (both enabled and disabled) for specified principal.java.util.LocalegetCurrentLocale()Returns the currently active locale.java.util.LocalegetDefaultDataLocale(java.lang.String principal)Returns the default data locale for specified principal.java.util.List<java.util.Locale>getEnabledDataLocales(java.lang.String principal)Returns a collection of enabled locales for specified principal.booleanisDataLocaleEnabled(java.util.Locale locale, java.lang.String principal)Checks if the given data locale is an active data locale for the given user.voidsetCurrentLocale(java.util.Locale locale)Changes the current locale to the given one.voidtoggleDataLocale(java.util.Locale locale, java.lang.String principal)Toggles the specified data locale.
-
-
-
Method Detail
-
getCurrentLocale
java.util.Locale getCurrentLocale()
Returns the currently active locale. You normally do not need to call this. All localized widget labels are automatically rendered using the current locale.- Returns:
- currently active locale
-
getAllLocales
java.util.List<java.util.Locale> getAllLocales()
Returns a list of all available locales.- Returns:
- a list of all available locales
-
getAllUILocales
default java.util.List<java.util.Locale> getAllUILocales()
Returns a list of all available locales.- Returns:
- a list of all available UI locales
-
setCurrentLocale
void setCurrentLocale(java.util.Locale locale)
Changes the current locale to the given one. After calling this you need to refresh the cockpit application (unless this is called before the application was rendered, e.g. shortly after login). You can useExecutions.sendRedirect(String)withnullas a parameter to re-render the application.- Parameters:
locale- the locale to be set as the current one
-
executeWithLocale
<T> T executeWithLocale(AbstractExecutionBody<T> executionBody, java.util.Locale locale)
Using this method you can execute code in a context of a different locale than the current one- Parameters:
executionBody- the execution bodylocale- the locale- Returns:
- the result of the execution body call or null if execution is without result
-
toggleDataLocale
void toggleDataLocale(java.util.Locale locale, java.lang.String principal)Toggles the specified data locale. Does nothing if the locale does not exist. Toggling data locale would enable or disable it for localized editors.- Parameters:
locale- to toggleprincipal- needed to filter available cockpit locales- Throws:
AvailableLocaleException- when an attempt to toggle the cockpit locale failed.
-
getAvailableDataLocales
java.util.List<java.util.Locale> getAvailableDataLocales(java.lang.String principal)
Returns a collection of available data locales (both enabled and disabled) for specified principal. An exception of typeAvailableLocaleExceptionis thrown when an attempt to load the cockpit locales failed.- Parameters:
principal- needed to filter available cockpit locales- Returns:
- collection of available locales
- Throws:
AvailableLocaleException- when an attempt to load the cockpit locales failed.
-
getEnabledDataLocales
java.util.List<java.util.Locale> getEnabledDataLocales(java.lang.String principal)
Returns a collection of enabled locales for specified principal. Only enabled locales are used to render localized attributes. By disabling locale you can reduce the visible localized data. An exception of typeAvailableLocaleExceptionis thrown when an attempt to load the cockpit locales failed.- Parameters:
principal- needed to filter available cockpit locales- Returns:
- collection of enabled locales
- Throws:
AvailableLocaleException- when an attempt to load the cockpit locales failed.
-
getDefaultDataLocale
java.util.Locale getDefaultDataLocale(java.lang.String principal)
Returns the default data locale for specified principal. A collapsed localized editor would only show the data using the default data locale. An exception of typeAvailableLocaleExceptionis thrown when an attempt to load the cockpit locales failed.- Parameters:
principal- needed to filter available cockpit locales- Returns:
Locale- Throws:
AvailableLocaleException- when an attempt to load the cockpit locales failed.
-
isDataLocaleEnabled
boolean isDataLocaleEnabled(java.util.Locale locale, java.lang.String principal)Checks if the given data locale is an active data locale for the given user.- Parameters:
locale- to checkprincipal- needed to filter available cockpit locales- Returns:
- true if data locale is enabled.
-
-