Package io.vertigo.core.locale
Interface LocaleManager
- All Superinterfaces:
Component,CoreComponent,Manager
- All Known Implementing Classes:
LocaleManagerImpl
The localization manager for applications managed by Vertigo,
supporting multilingual or more specifically, multidictionary management.
External resources are managed in dictionaries, where each resource is identified by a unique key:
- Author:
- pchretien
- See Also:
-
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> localeSupplier) Registers a strategy to choose a locale.voidregisterZoneSupplier(Supplier<ZoneId> zoneSupplier) Registers a strategy to choose a time zone.
-
Method Details
-
registerLocaleSupplier
Registers a strategy to choose a locale.- Parameters:
localeSupplier- Supplies a locale in a given context.
-
registerZoneSupplier
Registers a strategy to choose a time zone.- Parameters:
zoneSupplier- Supplies a time zone 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.- 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.- 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.- Parameters:
messageKey- Message key.locale- Locale.- Returns:
- Unformatted message in the language of the locale.
-
getCurrentLocale
Locale getCurrentLocale()Retrieves the current locale, corresponding to the current user if available, otherwise corresponds to the application's locale.- Returns:
- Current locale.
-
getCurrentZoneId
ZoneId getCurrentZoneId()Retrieves the current time zone, corresponding to the current user if available, otherwise corresponds to the application's time zone.- Returns:
- Current time zone.
-