Package be.gaudry.model.locale
Class LanguageHelper
java.lang.Object
be.gaudry.model.locale.LanguageHelper
Observable language helper. Allows to be notified in case of user
TODO : use a property file to read available locales. This will allow adding a language file by any user if he adds also a locale into the property file. See also be.gaudry.swing.utils.LanguageSwingHelper to get menu to modify the user language in case of use of the broldev.core.swing dependency. Provided by the broldev.core.model project.
language
modification
TODO : use a property file to read available locales. This will allow adding a language file by any user if he adds also a locale into the property file. See also be.gaudry.swing.utils.LanguageSwingHelper to get menu to modify the user language in case of use of the broldev.core.swing dependency. Provided by the broldev.core.model project.
- Since:
- 1.0 Jul 16, 2008, broldev.core.model 0.0.1-SNAPSHOT dependency
- Version:
- 1.2 Feb 19, 2009
- Author:
- Steph GAUDRY
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Adds an observer to the set of observers for this object, provided that it is not the same as some observer already in the set.static void
Adds aLocale
to the available locales.Returns an unmodifiable collection oflocales
available on the platformstatic Locale
Returns the preferredLocale
wich may be loaded from the Broldev property file, or the default user locale.static void
Removes an observer from the set of observers of this object.static void
removeLocale(Locale locale)
Removes aLocale
from the available locales.static void
Save preferred language for BrolDev applicationsstatic void
Sets locale.
-
Field Details
-
PROP_LOCALE
- See Also:
- Constant Field Values
-
-
Method Details
-
getAvailableLocales
Returns an unmodifiable collection oflocales
available on the platform- Returns:
- the available locales
-
getPreferredLocale
Returns the preferredLocale
wich may be loaded from the Broldev property file, or the default user locale.
Do not use this method to track language switch because this returns only preferred language; to get actual language, callLocale.getDefault();
- Returns:
- the computerLocale
- See Also:
Locale.getDefault()
-
setLocale
Sets locale.
This method sets the default Locale, but has no impact ongetPreferredLocale()
.
This method doesn't update specific GUI. In example, to update a Swing application, use the LanguageSwingHelper.setLocale method- Parameters:
locale
-
-
addLanguageHelperObserver
Adds an observer to the set of observers for this object, provided that it is not the same as some observer already in the set. The order in which notifications will be delivered to multiple observers is not specified.- Parameters:
pcl
- an observer to be added.
-
removeLanguageHelperObserver
Removes an observer from the set of observers of this object. Passingnull
to this method will have no effect.- Parameters:
pcl
- the observer to be removed.
-
addLocale
Adds aLocale
to the available locales. This involves than the new locale will be displayed into the language menu.
Thus, don't forget to provide all needed language resources files according to the new locale.- Parameters:
locale
-- Since:
- 1.1 (Feb 18, 2009)
-
removeLocale
Removes aLocale
from the available locales. This involves than the given locale will not displayed yet into the language menu.- Parameters:
locale
-- Since:
- 1.1 (Feb 18, 2009)
-
savePreference
public static void savePreference()Save preferred language for BrolDev applications- Since:
- 1.1 (Feb 19, 2009)
-