Interface ILocalizer
- All Known Implementing Classes:
ILocalizer.DummyLocalizer
,Localizer
public interface ILocalizer
Basic Interface for localizer implementations.
Also allows access to localizer instances per plugin.
- Since:
- 1.0.0
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ILocalizer
static final Pattern
static final Map<Class<? extends Plugin>,
ILocalizer> -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLocaleCodes
(Map<String, String> runtimeLocaleCodes) Add requested locale codes in runtime.static String
String[]
Returns all available locales.getMessage
(String key) Get a message.getMessage
(String key, String language) getMessage
(String key, CommandSender sender) static ILocalizer
getPluginLocalizer
(Class<? extends Plugin> plugin) static ILocalizer
getPluginLocalizer
(Plugin plugin) getValue
(String key, CommandSender sender) Returns all available locales.static boolean
isLocaleCode
(String message) localeBundle
(String language) default String
Translates a String with Placeholders.localize
(CommandSender sender, String message) Translates a String with Placeholders.plugin()
void
registerChild
(ILocalizer localizer) void
Sets the locale of the localizer instance.
-
Field Details
-
LOCALIZER
-
DEFAULT
-
LOCALIZATION_CODE
-
-
Method Details
-
getPluginLocalizer
-
getPluginLocalizer
-
plugin
Plugin plugin() -
escape
-
isLocaleCode
-
setLocale
Sets the locale of the localizer instance.- Parameters:
language
- language to set.
-
getMessage
Get a message.- Parameters:
key
- message key- Returns:
- message with replaced replacements if present.
-
getIncludedLocales
String[] getIncludedLocales()Returns all available locales.- Returns:
- array of registered locales.
-
includedLocales
Returns all available locales.- Returns:
- set of registered locales.
-
addLocaleCodes
Add requested locale codes in runtime.This has to be done before calling
setLocale(String)
Every key has one default value which will be added to the file if the key is not present.
- Parameters:
runtimeLocaleCodes
- map with locales codes to add.
-
getMessage
-
getValue
-
getMessage
-
getValue
-
getValue
-
localeBundle
-
defaultBundle
ResourceBundle defaultBundle() -
localize
Translates a String with Placeholders. Can handle multiple messages with replacements. Add replacements in the right order.- Parameters:
message
- Message to translate- Returns:
- Replaced Messages
- Since:
- 1.2.3
-
localize
Translates a String with Placeholders. Can handle multiple messages with replacements. Add replacements in the right order.- Parameters:
message
- Message to translate- Returns:
- Replaced Messages
- Since:
- 1.2.3
-
registerChild
-