public class ResourceBundleManager extends Object
Modifier and Type | Method and Description |
---|---|
void |
addBasename(String basename)
Add a basename pointing to resource bundles with translations.
|
void |
addBasenameToTop(String basename)
Like
addBasename(String) but adds the resource bundles referenced by the basename to
the top so that they will be searched before those provided by addBasename(String) . |
void |
addLocalizations(String key,
Locale locale,
Map<String,String> localizations)
Adds a map with additional localizations for a specified local to this manager.
|
String |
evaluateText(String messageKey,
Locale locale,
Map<String,Object> model)
Method to get a message and let it parse through Velocity.
|
String |
getI18NCustomText(String msgKey,
Locale locale)
Convenience method for getting a i18n key's value.
|
String |
getText(String msgKey,
Locale locale,
Object... arguments)
Convenience method for getting a i18n key's value.
|
Set<String> |
getUsedLanguageCodes() |
static String |
i18NCustomText(String msgKey,
Locale locale)
Convenience method for getting a i18n key's value.
|
static ResourceBundleManager |
instance() |
static boolean |
isCustomMessageKey(String msgKey)
Test whether the key belongs to a message that can be overridden in LocalizationManagement.
|
boolean |
isUsedLanguage(String languageCode) |
boolean |
knowsMessageKey(String msgKey,
Object[] args,
Locale locale) |
void |
removeBasename(String basename)
Removes the given basename.
|
void |
removeLocalizations(String key)
Removes the additional localization for the given key.
|
public static String i18NCustomText(String msgKey, Locale locale)
msgKey
- The possible message keylocale
- the current localepublic static ResourceBundleManager instance()
public static boolean isCustomMessageKey(String msgKey)
msgKey
- the key to testpublic void addBasename(String basename)
addLocalizations(String, Locale, Map)
basename
- The basename of the resource bundle without file extension or language code. If
the resource bundles should be searched on the classpath the basename has to start
with classpath:
.public void addBasenameToTop(String basename)
addBasename(String)
but adds the resource bundles referenced by the basename to
the top so that they will be searched before those provided by addBasename(String)
.
Translations provided by addLocalizations(String, Locale, Map)
are still having a
higher precedence.basename
- The basename of the resource bundle without file extension or language code. If
the resource bundles should be searched on the classpath the basename has to start
with classpath:
.public void addLocalizations(String key, Locale locale, Map<String,String> localizations)
key
- Key of the localizations. If there is already a dictionary for this key, it will
be overwritten.locale
- The locale the localizations are for.localizations
- The localizations. The key is the message key and and value the value.public String evaluateText(String messageKey, Locale locale, Map<String,Object> model)
messageKey
- Message key to load.locale
- The locale.model
- The model for the Velocity context.public String getI18NCustomText(String msgKey, Locale locale)
msgKey
- The possible message keylocale
- the current localepublic String getText(String msgKey, Locale locale, Object... arguments)
msgKey
- The message keylocale
- the current locale.arguments
- Argument for the message.public Set<String> getUsedLanguageCodes()
public boolean isUsedLanguage(String languageCode)
languageCode
- The language code to check.True
, if there are localizations for the given language code are
available.public boolean knowsMessageKey(String msgKey, Object[] args, Locale locale)
msgKey
- The message keyargs
- the arguments for the messagelocale
- the current localepublic void removeBasename(String basename)
basename
- The basename.public void removeLocalizations(String key)
key
- Key of the localizations.Copyright © 2019 Communote team. All rights reserved.