|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfi.hu.cs.titokone.Translator
This class deals with translating strings. It also remembers which language is currently set, but does not know specifically what languages are currently available.
Field Summary | |
private static java.util.Locale |
currentLocale
This field stores the current locale. |
static java.util.Locale |
defaultLocale
This field contains the default locale. |
private static java.util.ResourceBundle |
defaultTranslations
This field stores the default ResourceBundle. |
static java.lang.String |
resourceFamilyName
This name identifies the resource files containing translations for this software. |
private static boolean |
TESTING
This field should be false during normal operation. |
private static java.util.ResourceBundle |
translations
This field stores the current ResourceBundle in use. |
Constructor Summary | |
Translator()
|
Method Summary | |
static java.util.ResourceBundle |
getResourceBundle()
This method returns the resource bundle in use. |
static void |
setLocale(java.util.Locale newLocale)
This method sets the current locale in use and fetches a corresponding ResourceBundle that contains the translations most suitable for this locale. |
static void |
setLocale(java.util.Locale newLocale,
java.util.ResourceBundle newTranslations)
This method sets the current locale in use and tries to fetch the translation from translationPath. |
static java.lang.String |
translate(java.lang.String keyString)
This function translates a fixed string to the currently used language. |
static java.lang.String |
translate(java.lang.String keyString,
java.lang.String[] parameters)
This function translates a template string to the currently used language and replaces any {i} markers in it with strings from the parameters array. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final boolean TESTING
public static final java.lang.String resourceFamilyName
public static final java.util.Locale defaultLocale
private static java.util.Locale currentLocale
private static java.util.ResourceBundle defaultTranslations
private static java.util.ResourceBundle translations
Constructor Detail |
public Translator()
Method Detail |
public static java.lang.String translate(java.lang.String keyString)
keyString
- A string key that identifies the translation in a
Translations*class file.
public static java.lang.String translate(java.lang.String keyString, java.lang.String[] parameters)
keyString
- A string key that identifies the translation in a
Translations*class file.parameters
- A string array containing strings to replace {i}
markers in the string in order - that is, parameters[0] replaces {0},
parameters[1] replaces {1} etc.
public static void setLocale(java.util.Locale newLocale)
newLocale
- The locale to switch to, eg. new Locale("fi",
"FI").public static void setLocale(java.util.Locale newLocale, java.util.ResourceBundle newTranslations)
newLocale
- The locale to switch to, eg. new Locale("fi",
"FI").newTranslations
- A class containing the translations for this
locale. If the translations are located in the standard place,
setLocale(Locale) can be used.public static java.util.ResourceBundle getResourceBundle()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |