Class LocalizationUtils
java.lang.Object
de.codecamp.messages.spring.vaadin.LocalizationUtils
Utility methods related to message access in Vaadin UIs.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Locale[]getCandidateLocales(boolean includeParentLevels) Returns locales in the order they should be used to attempt to lookup localized resources.static MessageAccessorgetL10n()Returns access to localized messages and related information for the locale of the current UI.static voidinjectMessageProxies(com.vaadin.flow.component.Component component) Inject message proxies into any appropriate fields of the given component.static voidlocalizeComponents(com.vaadin.flow.component.Component composite) Localizes the components stored in the fields of the given component instance usingLocalizedPropertyor one of the premadeLocalized*annotations, likeLocalizedText/LocalizedTextMessage.
-
Constructor Details
-
LocalizationUtils
public LocalizationUtils()
-
-
Method Details
-
getCandidateLocales
Returns locales in the order they should be used to attempt to lookup localized resources.This can be useful to achieve consistent behavior when other sources for localizations need to also be accessed. The result can optionally contain the parent chains for each main locale, depending on whether those other sources do handle that fallback on their own.
- Parameters:
includeParentLevels- whether to include implicit parent locales (other than theroot locale)- Returns:
- the locales in the order they should be used to attempt to lookup localized resources
- See Also:
-
localizeComponents
public static void localizeComponents(com.vaadin.flow.component.Component composite) Localizes the components stored in the fields of the given component instance usingLocalizedPropertyor one of the premadeLocalized*annotations, likeLocalizedText/LocalizedTextMessage.- Parameters:
composite- the component whose fields should be localized
-
injectMessageProxies
public static void injectMessageProxies(com.vaadin.flow.component.Component component) Inject message proxies into any appropriate fields of the given component.- Parameters:
component- the component using message proxies
-
getL10n
Returns access to localized messages and related information for the locale of the current UI. The returned objects are serializable, so it's possible to keep references to them in (serializable) Vaadin components.- Returns:
- access to localized messages
-