Class LanguageHelper

java.lang.Object
be.gaudry.model.locale.LanguageHelper

public class LanguageHelper extends Object
Observable language helper. Allows to be notified in case of user 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 Details

  • Method Details

    • getAvailableLocales

      public static List<Locale> getAvailableLocales()
      Returns an unmodifiable collection of locales available on the platform
      Returns:
      the available locales
    • getPreferredLocale

      public static Locale getPreferredLocale()
      Returns the preferred Locale 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, call Locale.getDefault();
      Returns:
      the computerLocale
      See Also:
      Locale.getDefault()
    • setLocale

      public static void setLocale(Locale locale)
      Sets locale.

      This method sets the default Locale, but has no impact on getPreferredLocale().

      This method doesn't update specific GUI. In example, to update a Swing application, use the LanguageSwingHelper.setLocale method
      Parameters:
      locale -
    • addLanguageHelperObserver

      public static void addLanguageHelperObserver(PropertyChangeListener pcl)
      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

      public static void removeLanguageHelperObserver(PropertyChangeListener pcl)
      Removes an observer from the set of observers of this object. Passing null to this method will have no effect.
      Parameters:
      pcl - the observer to be removed.
    • addLocale

      public static void addLocale(Locale locale)
      Adds a Locale 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

      public static void removeLocale(Locale locale)
      Removes a Locale 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)