public final class LanguageManager extends Object
LanguageManager allows you to easily manage application language Dictionarys.
Dictionarys could be either loaded from structured xml files or added directly from the code.Language,
Dictionary| Constructor and Description |
|---|
LanguageManager() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addDictionary(Dictionary dictionary)
Adds new
Dictionary. |
static void |
addDictionaryListener(DictionaryListener listener)
Adds new
DictionaryListener. |
static void |
addDictionaryListener(JComponent component,
DictionaryListener listener)
Adds new
LanguageListener. |
static void |
addLanguageListener(JComponent component,
LanguageListener listener)
Adds new
LanguageListener. |
static void |
addLanguageListener(LanguageListener listener)
Adds new
LanguageListener. |
static void |
clearDictionaries()
Removes all added dictionaries including WebLaF ones.
|
List<Locale> |
getAllLocales()
|
static Dictionary |
getDictionaries()
Returns
Dictionary containing all registered Dictionarys. |
static Language |
getLanguage()
Returns currently used
Language. |
static String |
getLanguageTitle(Language language)
|
static Locale |
getLocale()
Returns currently used
Locale. |
static String |
getLocaleTitle(Locale locale)
|
static List<Locale> |
getSupportedLocales()
|
static List<Locale> |
getSupportedLocales(List<Locale> locales)
|
static void |
initialize()
Initializes LanguageManager settings.
|
static boolean |
isCurrentLanguage(Language language)
Returns whether the specified
Language is currently used or not. |
static boolean |
isCurrentLocale(Locale locale)
Returns whether the specified
Locale is currently used or not. |
static boolean |
isSuportedLanguage(Language language)
Returns whether or not specified
Language is supported. |
static boolean |
isSuportedLocale(Locale locale)
Returns whether or not specified
Locale is supported. |
static void |
removeDictionary(Dictionary dictionary)
Removes existing
Dictionary. |
static void |
removeDictionaryListener(DictionaryListener listener)
Removes
DictionaryListener. |
static void |
removeDictionaryListener(JComponent component,
DictionaryListener listener)
Removes
LanguageListener. |
static void |
removeLanguageListener(JComponent component,
LanguageListener listener)
Removes
LanguageListener. |
static void |
removeLanguageListener(LanguageListener listener)
Removes
LanguageListener. |
static void |
setLanguage(Language language)
Sets currently used
Language. |
static void |
setLocale(Locale locale)
Sets currently used
Locale. |
public static void initialize()
@NotNull public static Dictionary getDictionaries()
Dictionary containing all registered Dictionarys.Dictionary containing all registered Dictionarys@NotNull public static String getLanguageTitle(@NotNull Language language)
language - Language to get title forLanguage title based on TranslationInformation provided within added Dictionarys@NotNull public static String getLocaleTitle(@NotNull Locale locale)
Locale title based on TranslationInformation provided within added Dictionarys.
If no TranslationInformation can be found for Locale its default methods will be used to generate title.locale - Locale to get title forLocale title based on TranslationInformation provided within added Dictionarys@NotNull public List<Locale> getAllLocales()
List of all Locale from all Dictionarys@NotNull public static List<Locale> getSupportedLocales()
List of Locales that are supported by all Dictionarys.
Language codes are used to detect whether or not specific Locale is supported.
We can't say that for instance "en_US" Locale is not supported if we have "en" or "en_GB" translation available.
Even though it is not strict "supported" case it is much better than having fully distinct translation for each country.List of Locales supported by all Dictionarys@NotNull public static List<Locale> getSupportedLocales(@NotNull List<Locale> locales)
locales - List of Locales to filterList of Locales that are supported by all Dictionaryspublic static boolean isSuportedLanguage(@NotNull Language language)
Language is supported.public static boolean isSuportedLocale(@NotNull Locale locale)
Locale is supported.public static void addDictionary(@NotNull Dictionary dictionary)
Dictionary.
This method call may cause a lot of UI updates depending on amount of translations contained.
If added dictionary contains records with existing keys they will override previously added ones.dictionary - dictionary to addpublic static void removeDictionary(@NotNull Dictionary dictionary)
Dictionary.
This method call may cause a lot of UI updates depending on amount of translations contained.dictionary - dictionary to removepublic static void clearDictionaries()
@NotNull public static Locale getLocale()
Locale.Localepublic static boolean isCurrentLocale(@NotNull Locale locale)
Locale is currently used or not.public static void setLocale(@NotNull Locale locale)
Locale.locale - Locale to use@NotNull public static Language getLanguage()
Language.Languagepublic static boolean isCurrentLanguage(@NotNull Language language)
Language is currently used or not.public static void setLanguage(@NotNull Language language)
Language.language - Language to usepublic static void addLanguageListener(@NotNull LanguageListener listener)
LanguageListener.listener - LanguageListener to addpublic static void removeLanguageListener(@NotNull LanguageListener listener)
LanguageListener.listener - LanguageListener to removepublic static void addLanguageListener(@NotNull JComponent component, @NotNull LanguageListener listener)
LanguageListener.component - JComponent to add LanguageListener forlistener - LanguageListener to addpublic static void removeLanguageListener(@NotNull JComponent component, @NotNull LanguageListener listener)
LanguageListener.component - JComponent to remove LanguageListener fromlistener - LanguageListener to removepublic static void addDictionaryListener(@NotNull DictionaryListener listener)
DictionaryListener.listener - DictionaryListener to addpublic static void removeDictionaryListener(@NotNull DictionaryListener listener)
DictionaryListener.listener - DictionaryListener to removepublic static void addDictionaryListener(@NotNull JComponent component, @NotNull DictionaryListener listener)
LanguageListener.component - JComponent to add LanguageListener forlistener - LanguageListener to addpublic static void removeDictionaryListener(@NotNull JComponent component, @NotNull DictionaryListener listener)
LanguageListener.component - JComponent to remove LanguageListener fromlistener - LanguageListener to removeCopyright © 2020. All rights reserved.