Package io.vertigo.core.impl.locale
Class LocaleManagerImpl
java.lang.Object
io.vertigo.core.impl.locale.LocaleManagerImpl
- All Implemented Interfaces:
LocaleManager,Component,CoreComponent,Manager
This class manages locales and provides localization services.
- Author:
- pchretien
-
Constructor Summary
ConstructorsConstructorDescriptionLocaleManagerImpl(String locales, Optional<String> defaultZoneId) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(String baseName, LocaleMessageKey[] enums) Adds a resource dictionary.Retrieves the current locale, corresponding to the current user if available, otherwise corresponds to the application's locale.Retrieves the current time zone, corresponding to the current user if available, otherwise corresponds to the application's time zone.getMessage(LocaleMessageKey messageKey, Locale locale) Retrieves the unformatted label of a message identified by its key.voidoverride(String baseName, LocaleMessageKey[] enums) Overrides a resource dictionary.voidregisterLocaleSupplier(Supplier<Locale> newLocaleSupplier) Registers a strategy to choose a locale.voidregisterZoneSupplier(Supplier<ZoneId> newZoneSupplier) Registers a strategy to choose a time zone.
-
Constructor Details
-
LocaleManagerImpl
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
Registers a strategy to choose a time zone.- Specified by:
registerZoneSupplierin interfaceLocaleManager- Parameters:
newZoneSupplier- Supplies a time zone in a given context.
-
registerLocaleSupplier
Registers a strategy to choose a locale.- Specified by:
registerLocaleSupplierin interfaceLocaleManager- Parameters:
newLocaleSupplier- Supplies a locale in a given context.
-
add
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:
addin interfaceLocaleManager- Parameters:
baseName- Name and path of the properties file.enums- Enumeration (enum) controlling the managed resources.
-
override
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:
overridein interfaceLocaleManager- Parameters:
baseName- Name and path of the properties file.enums- Enumeration (enum) controlling the managed resources.
-
getMessage
Retrieves the unformatted label of a message identified by its key. Returns null if the message is not found.- Specified by:
getMessagein interfaceLocaleManager- Parameters:
messageKey- Message key.locale- Locale.- Returns:
- Unformatted message in the language of the locale.
-
getCurrentZoneId
Retrieves the current time zone, corresponding to the current user if available, otherwise corresponds to the application's time zone.- Specified by:
getCurrentZoneIdin interfaceLocaleManager- Returns:
- Current time zone.
-
getCurrentLocale
Retrieves the current locale, corresponding to the current user if available, otherwise corresponds to the application's locale.- Specified by:
getCurrentLocalein interfaceLocaleManager- Returns:
- Current locale.
-