Class LocaleManagerImpl

java.lang.Object
io.vertigo.core.impl.locale.LocaleManagerImpl
All Implemented Interfaces:
LocaleManager, Component, CoreComponent, Manager

public final class LocaleManagerImpl extends Object implements LocaleManager
This class manages locales and provides localization services.
Author:
pchretien
  • Constructor Details

    • LocaleManagerImpl

      @Inject public LocaleManagerImpl(String locales, Optional<String> defaultZoneId)
      Constructor. Exceptions are always thrown. Field labels are not localized. The first Locale is used if no user is declared (batch cases). You must specify the list of locales as a string examples : Locale.french : 'fr' Locale.FRANCE + Locale.us : 'fr_FR,us' A locale is defined by a language{_Country{_Variant}}
      Parameters:
      locales - List of locales managed by the application.
      defaultZoneId - Default ZoneId used by the application.
  • Method Details

    • registerZoneSupplier

      public void registerZoneSupplier(Supplier<ZoneId> newZoneSupplier)
      Registers a strategy to choose a time zone.
      Specified by:
      registerZoneSupplier in interface LocaleManager
      Parameters:
      newZoneSupplier - Supplies a time zone in a given context.
    • registerLocaleSupplier

      public void registerLocaleSupplier(Supplier<Locale> newLocaleSupplier)
      Registers a strategy to choose a locale.
      Specified by:
      registerLocaleSupplier in interface LocaleManager
      Parameters:
      newLocaleSupplier - Supplies a locale in a given context.
    • add

      public void add(String baseName, LocaleMessageKey[] enums)
      Adds a resource dictionary. All resources identified by a key must be present in the properties file. This method is not synchronized and should be called at application startup.
      Specified by:
      add in interface LocaleManager
      Parameters:
      baseName - Name and path of the properties file.
      enums - Enumeration (enum) controlling the managed resources.
    • override

      public void override(String baseName, LocaleMessageKey[] enums)
      Overrides a resource dictionary. This method is not synchronized and should be called at application startup. It is possible to override only one property or a specific dictionary.
      Specified by:
      override in interface LocaleManager
      Parameters:
      baseName - Name and path of the properties file.
      enums - Enumeration (enum) controlling the managed resources.
    • getMessage

      public String getMessage(LocaleMessageKey messageKey, Locale locale)
      Retrieves the unformatted label of a message identified by its key. Returns null if the message is not found.
      Specified by:
      getMessage in interface LocaleManager
      Parameters:
      messageKey - Message key.
      locale - Locale.
      Returns:
      Unformatted message in the language of the locale.
    • getCurrentZoneId

      public ZoneId getCurrentZoneId()
      Retrieves the current time zone, corresponding to the current user if available, otherwise corresponds to the application's time zone.
      Specified by:
      getCurrentZoneId in interface LocaleManager
      Returns:
      Current time zone.
    • getCurrentLocale

      public Locale getCurrentLocale()
      Retrieves the current locale, corresponding to the current user if available, otherwise corresponds to the application's locale.
      Specified by:
      getCurrentLocale in interface LocaleManager
      Returns:
      Current locale.