Interface Localizer
- All Known Implementing Classes:
FluavaLocalizer
A Localizer is used to localize a given key for a specific bundle and locale.
Implementations of this interface will commonly delegate the task to a localization framework like
Fluava.
For an example implementation take a look at FluavaLocalizer
-
Method Summary
Modifier and TypeMethodDescriptionThis method localizes a given key for a specific bundle and locale.This method localizes a given key (coming from JDA'sLocalizationFunction) for a specific bundle and locale.
-
Method Details
-
localize
Optional<String> localize(Locale locale, String bundle, String key, Map<String, @Nullable Object> arguments) This method localizes a given key for a specific bundle and locale. If no message is found for this combination of locale, bundle and key or an error occurredOptional.empty()should be returned.- Parameters:
locale- the asked for localebundle- the bundle to search the key inkey- the key of the message as provided by the userarguments- values for placeholder in the message- Returns:
- the localized message or
Optional.empty()if no key is found/an error occurred
-
localizeJDA
default Optional<String> localizeJDA(Locale locale, String bundle, String key, Map<String, @Nullable Object> arguments) This method localizes a given key (coming from JDA's
LocalizationFunction) for a specific bundle and locale. If no message is found for this combination of locale, bundle and key or an error occurredOptional.empty()should be returned.The difference to
localize(Locale, String, String, Map)is, that this method is only used inside our implementation ofLocalizationFunction, thus the keys always follow the JDA format (parts are separated by a dot.).For example, project fluent (
Fluava) disallows.as a "normal" separator in localization keys, therefore we have to replace all.with-and then pass it to thelocalize(Locale, String, String, Map)method.- Parameters:
locale- the asked for localebundle- the bundle to search the key inkey- the key of the message as provided by JDAarguments- values for placeholder in the message- Returns:
- the localized message or
Optional.empty()if no key is found/an error occurred
-