org.apache.avalon.fortress.examples.components
Class TranslatorImpl
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable
org.apache.avalon.fortress.examples.components.TranslatorImpl
- All Implemented Interfaces:
- Configurable, Instrumentable, LogEnabled, Translator
- public class TranslatorImpl
- extends AbstractLogEnabledInstrumentable
- implements Translator, Configurable
Simple implementation of the 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>
- Version:
- CVS $Revision: 1.10 $ $Date: 2004/02/24 22:31:21 $
- Author:
- Avalon Development Team
Fields inherited from interface org.apache.avalon.fortress.examples.components.Translator |
ROLE |
Method Summary |
void |
configure(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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TranslatorImpl
public TranslatorImpl()
- Create a new TranslatorImpl.
configure
public void configure(Configuration config)
throws ConfigurationException
- Configures this component. Reads configuration information
from container and appropriately sets up the internal mapping
array. Configuration syntax is specified in the class header.
- Specified by:
configure
in interface Configurable
- Parameters:
config
- Configuration
details
- Throws:
ConfigurationException
- if an error occurs
getSupportedLanguages
public java.lang.String[] getSupportedLanguages(java.lang.String key)
getSupportedLanguages
returns an array of String
objects detailing which languages are supported for the given
key.
- Specified by:
getSupportedLanguages
in interface Translator
- Parameters:
key
- a String
value identifying a translation
- Returns:
- a
String[]
array containing available language
translations for the given key
getTranslation
public 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
.
- Specified by:
getTranslation
in interface Translator
- Parameters:
key
- a String
value identifying a translationlanguage
- a String
value identifying the language
- Returns:
- translated text
Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.