public class TranslatorImpl extends org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable implements Translator, org.apache.avalon.framework.configuration.Configurable
Translator component, which
maintains a simple mapping of keys to translated values, created during
configuration.
Configuration format:
<translations>
<entry key="hello-world">
<value language="Deutsch">Hallo Welt</value>
<value language="English">Hello World</value>
</entry>
</translations>
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map |
m_keys |
private org.apache.excalibur.instrument.CounterInstrument |
m_translationsInstrument |
ROLE| Constructor and Description |
|---|
TranslatorImpl()
Create a new TranslatorImpl.
|
| Modifier and Type | Method and Description |
|---|---|
void |
configure(org.apache.avalon.framework.configuration.Configuration config)
Configures this component.
|
java.lang.String[] |
getSupportedLanguages(java.lang.String key)
getSupportedLanguages returns an array of String
objects detailing which languages are supported for the given
key. |
java.lang.String |
getTranslation(java.lang.String key,
java.lang.String language)
getTranslation obtains a translation for a given
key in a given language. |
addChildInstrumentable, addInstrument, getChildInstrumentables, getInstrumentableName, getInstruments, setInstrumentableNameprivate org.apache.excalibur.instrument.CounterInstrument m_translationsInstrument
private java.util.Map m_keys
public void configure(org.apache.avalon.framework.configuration.Configuration config)
throws org.apache.avalon.framework.configuration.ConfigurationException
configure in interface org.apache.avalon.framework.configuration.Configurableconfig - Configuration detailsorg.apache.avalon.framework.configuration.ConfigurationException - if an error occurspublic java.lang.String[] getSupportedLanguages(java.lang.String key)
getSupportedLanguages returns an array of String
objects detailing which languages are supported for the given
key.getSupportedLanguages in interface Translatorkey - a String value identifying a translationString[] array containing available language
translations for the given keypublic java.lang.String getTranslation(java.lang.String key,
java.lang.String language)
getTranslation obtains a translation for a given
key in a given language. The language parameter must be listed
in getSupportedLanguages.getTranslation in interface Translatorkey - a String value identifying a translationlanguage - a String value identifying the language