java.lang.Object
de.codecamp.messages.spring.vaadin.LocalizationUtils

public class LocalizationUtils extends Object
Utility methods related to message access in Vaadin UIs.
  • Constructor Details

    • LocalizationUtils

      public LocalizationUtils()
  • Method Details

    • getCandidateLocales

      public static Locale[] getCandidateLocales(boolean includeParentLevels)
      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 the root 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 using LocalizedProperty or one of the premade Localized* annotations, like LocalizedText / 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

      public static MessageAccessor 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