|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ehsbe.commons.gui.wizard.TranslatorAdapter
public class TranslatorAdapter
General purpose translator, which might be used to do l10n lookups for a task. It uses either resource bundles for lookups or appropriate component properties.
Constructor Summary | |
---|---|
TranslatorAdapter(Class<?> clazz,
String name,
Locale locale)
Creates a new translator. |
|
TranslatorAdapter(JComponent wizardPage)
Deduces a translator from the given component. |
Method Summary | |
---|---|
Locale |
getLocale()
Get the locale currently used for translations. |
void |
setLocale(Locale locale)
Set the locale, which should be use for translations. |
String |
xlate(String prefix,
String name)
Translate the given name wrt. to the given prefix. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TranslatorAdapter(Class<?> clazz, String name, Locale locale)
clazz
- class to use to determine the package name, which contains
the resource bundle in its /res/
sub directory.name
- the name of the resource bundle to lookup.locale
- initial locale to use.Misc.getResourcePath(Object)
public TranslatorAdapter(JComponent wizardPage)
null
value.
NOTE: This variant ignores any locale settings made here since it
queries the given component properties. Except the components name,
all values are obtained by asking the component's client properties
using the given prefix + name
as key.
If it contains no value for the Task.PREFIX_TT
,
its JComponent.getToolTipText()
method will be used.
wizardPage
- component to use to create the translator.Component.getName()
,
JComponent.getClientProperty(Object)
Method Detail |
---|
public Locale getLocale()
getLocale
in interface Translator
null
if not set and default locale is used, the locale
in use otherwise.public void setLocale(Locale locale)
setLocale
in interface Translator
locale
- Locale to set. If null
, the default locale
should be used.Locale.getDefault()
public String xlate(String prefix, String name)
One should never let an exception pass or throw here. Instead catch and log.
xlate
in interface Translator
prefix
- key prefix. Usually a purpose indicator.name
- key name. Usually an instance ID.
null
).
|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |