net.sf.jeters.internationalization
Interface Translatable
- All Known Implementing Classes:
- AssistedComponent, AssistedTranslatable, DefaultGUI, FileIO, MediaWikiIO, RegExReplacer, RegExReplacer_User, UserIO
public interface Translatable
interface for components with strings that can be translated to different
languages. Components implementing Translatable will get ResourceBundle
objects depending on JETERS current locale and the .properties files
available for the component.
In many cases, it is much more convenient to use
AssistedTranslatable
instead of directly
implementing this interface. However, the following informations about
.properties files apply to AssistedTranslatable, too.
Property files must be named lang_[language]_[COUNTRY].properties
(where [language] and [COUNTRY] identify the locale the file is to be used
for, the possible values are those from ISO 639-1 and ISO 3166-1).
They must be placed in a folder languages/[ComponentClassSimpleName]/
either relative to JETERS' root directory or to the root dir
inside the component's jar.
Please note that [ComponentClassSimpleName] refers to the output of
.getSimpleName()
applied to the component's class.
So if you want to internationalize your component, do the following:
- implement Translatable, store the ResourceBundle in an attribute
- instead of coding Strings directly (e.g. "Cancel"), use the
ResourceBundle by calling its getText(String) method
(e.g. getText("buttonCancel"))
- create a lang.properties file that contains the Strings in the
default language, using proper syntax. Example:
buttonCancel = Cancel
- create lang_[language]_[COUNTRY].properties containing the
translations, e.g. a German translation lang_de_DE containing
buttonCancel = Abbrechen
- place your .properties files in the proper place
(as explained above)
Additional possibility: Including a displayName property
in your .properties allows you to set localized component names.
- Author:
- Tobias Knerr
Method Summary |
void |
setLanguageResourceBundle(java.util.ResourceBundle langRB)
sets the ResourceBundle that contains the messages to use |
setLanguageResourceBundle
void setLanguageResourceBundle(java.util.ResourceBundle langRB)
- sets the ResourceBundle that contains the messages to use
- Parameters:
langRB
- ResourceBundle to retrieve Strings from