|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcdox.util.Localizer
This is a wrapper class that handles several localized language files. To use this, you must have some language files somewhere. If you have a package com.microsoft.stupid you could have a dir called lang there with a language file `deu'. Then you would call new Localizer() or setLang() with (Locale.GERMAN,"/com/microsoft/stupid/lang/") to initialize this class.
The language files must be named according to ISO 639-2/T (three letter language code), english would be "eng", german "deu" etc.
The language files can also be used to provide you with keystrokes. If provideKeystrokes is set to true, every string that is returned will be stripped from & chars. If set to false (which is the default), the & chars are also returned.
Constructor Summary | |
Localizer(java.util.Locale loc,
java.lang.String path)
Constructs a new Localizer. |
|
Localizer(java.lang.String lng,
java.lang.String path)
Creates a new Localizer instance. |
Method Summary | |
java.lang.String |
get(java.lang.String key)
Returns the localized String mapping the key. |
java.lang.String |
get(java.lang.String key,
java.lang.String[] param)
Returns the localized String mapping the key. |
java.util.Properties |
getAvailableLanguages()
Returns the available languages. |
java.lang.String |
getLanguageCode()
Returns the ISO3 language code for this localizer. |
static Localizer |
getLocalizer(java.lang.String language)
This method just returns a Localizer for the utilities packages. |
char |
getStroke(java.lang.String key)
Returns the key stroke for this object or ' ', if none has been specified. |
void |
provideKeystrokes(boolean yes)
Sets whether the Localizer should provide you with keystrokes and strip the & characters or not. |
boolean |
providesKeystrokes()
Returns whether the Localizer provides you with keystrokes and strips the & character or not. |
boolean |
setLang(java.util.Locale loc,
java.lang.String path)
Sets the new language for this Localizer. |
boolean |
setLang(java.lang.String path)
Sets the new language for this Localizer. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Localizer(java.util.Locale loc, java.lang.String path) throws java.io.IOException
loc
- the locale which language should be usedpath
- the path to the new language file
java.io.IOException
- if no language file for loc had been foundpublic Localizer(java.lang.String lng, java.lang.String path) throws java.io.IOException
Localizer
instance.
lng
- a String
value indicating the language.path
- a String
value indicating the package path.
java.io.IOException
- if an error occurs.Method Detail |
public boolean setLang(java.util.Locale loc, java.lang.String path)
loc
- the locale which language should be usedpath
- the path to the new language file
public boolean setLang(java.lang.String path)
path
- the path to the new language file, ending with the iso3 language code.
public java.lang.String getLanguageCode()
public java.util.Properties getAvailableLanguages()
availablelanguages
in the languages package where all other language
files are for this to work. If no such file exists, an empty properties object will
be returned.
public void provideKeystrokes(boolean yes)
yes
- true if you want the keystrokes.public boolean providesKeystrokes()
public char getStroke(java.lang.String key)
key
- the key.
public java.lang.String get(java.lang.String key)
key
- the key
public java.lang.String get(java.lang.String key, java.lang.String[] param)
key
- the keyparam
- the replacements.
public static Localizer getLocalizer(java.lang.String language)
language
- the language for the localizer.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |