Modifier and Type | Field and Description |
---|---|
protected static Log |
LOG
Logs WARN messages if translations are inconsistent (override each other).
|
Constructor and Description |
---|
Babelfish() |
Modifier and Type | Method and Description |
---|---|
protected Translation |
get(String property,
String fallback,
boolean create)
Retrieves the Translation for the given property.
|
Stream<Translation> |
getEntriesStartingWith(String key)
Enumerates all translations which key starts with the given prefix
|
List<String> |
getLoadedResourceBundles()
Returns a list of all loaded resource bundles.
|
Stream<Translation> |
getTranslations(String filter)
Enumerates all translations matching the given filter.
|
protected void |
init(Classpath classpath)
Initializes the translation engine by using the given classpath.
|
protected void |
reloadBundle(String name) |
void |
reportMissingTranslations()
Throws an exception if any unknown translations where encountered so far.
|
protected static final Log LOG
public Stream<Translation> getTranslations(@Nullable String filter)
filter
- the filter to apply when enumerating translations. The given filter must occur in either the key
or in one of the translations.public Stream<Translation> getEntriesStartingWith(@Nonnull String key)
key
- the prefix with which the key must startprotected Translation get(@Nonnull String property, @Nullable String fallback, boolean create)
If no matching entry is found, the given fallback is used. If still no match was found, either a new one is create (if create is true) or false otherwise.
property
- the property key for which a translation is requiredfallback
- a fallback key, if no translation is found. May be null.create
- determines if a new Translation is created if non-existentpublic List<String> getLoadedResourceBundles()
protected void init(Classpath classpath)
Scans for all .properties files matching PROPERTIES_FILE and loads their contents.
classpath
- the classpath used to discover all relevant properties filesprotected void reloadBundle(String name)
public void reportMissingTranslations()
This is called by Sirius.stop()
if the framework was initialized as test
environment. The idea is to break unit-tests if unknown translations are encountered.
HandledException
- if unknown translations where detected.Copyright © 2018. All rights reserved.