Package jpicedt

Class Localizer


  • public class Localizer
    extends java.lang.Object
    Localizer for all classes of the jpicedt's tree.
    It uses "lang/i18n_xx_yy.properties" resource file, where xx_yy is the Locale. If not found, uses "lang/i18n.properties" (same as i18n_en.properties) As of 2005/12, support for localized help-files added by Jobst Hoffmann.
    Since:
    jpicedt 1.3.2
    Version:
    $Id: Localizer.java,v 1.10.2.1 2007/09/02 11:55:59 reynal Exp $
    Author:
    Sylvain Reynal
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String KEY_LANGUAGE
      the key used to retrieve the locale from the preferences file
    • Constructor Summary

      Constructors 
      Constructor Description
      Localizer()
      Create a new Localizer instance init'd from the default locale
      Localizer​(java.util.Properties preferences)
      Create a new Localizer instance init'd from the given Properties object
    • Field Detail

      • KEY_LANGUAGE

        public static final java.lang.String KEY_LANGUAGE
        the key used to retrieve the locale from the preferences file
        See Also:
        Constant Field Values
    • Constructor Detail

      • Localizer

        public Localizer()
        Create a new Localizer instance init'd from the default locale
      • Localizer

        public Localizer​(java.util.Properties preferences)
        Create a new Localizer instance init'd from the given Properties object
    • Method Detail

      • currentLocalizer

        public static Localizer currentLocalizer()
        Returns:
        the current Localizer
      • setCurrentLocalizer

        public static void setCurrentLocalizer​(Localizer aLocalizer)
        set the Localizer that should be used for the jpicedt's class library
      • isLocaleSupported

        public boolean isLocaleSupported​(java.util.Locale l)
        Returns:
        whether the given Locale is supported by this Localizer or not. Only the language is checked, not the country, nor the variant.
      • getSupportedLocales

        public java.util.Locale[] getSupportedLocales()
        Return an array containing all Locales this localizer supports, by looking up the "lang/" subdirectory.
      • getSupportedDisplayLanguages

        public java.lang.String[] getSupportedDisplayLanguages()
        Return an array containing all languages this localizer supports, returned in the same format as Locale.getDisplayLanguage(inLocale), yet localized using the current Locale e.g. "anglais,espagnol,francais,portugais" is current locale is "fr".
      • getCurrentLocale

        public java.util.Locale getCurrentLocale()
        Return the current Locale for this Localizer
      • getCurrentDisplayLanguage

        public java.lang.String getCurrentDisplayLanguage()
        Return the current Locale for this Localizer
      • getDefaultLanguage

        public java.lang.String getDefaultLanguage()
        Returns:
        the default language (localized using the current locale), in the same format as returned by Locale.getDisplayLanguage() and getSupportedLanguages(), e.g. "anglais" if current locale is "fr", and default locale is "en".
      • init

        public void init()
        Init ResourceBundle using OS's default Locale
      • init

        public void init​(java.util.Properties preferences)
        (Re)init from a Properties object.

        First a Locale is fetched from the given Properties object, using key=PREFERENCE_KEY (values having to be valid ISO639 codes acceptable by the Locale constructor) then a ResourceBundle is loaded using this Locale. Finally, the current Locale is written back to the given Properties to reflect change (if any, e.g. if the Locale was not found in the Properties object).

      • get

        public java.lang.String get​(java.lang.String key)
        Returns:
        a localized version of the given key ; the key if no ResourceBundle was found.
        Since:
        PicEdt 1.2
      • getActionLocalizer

        public ActionLocalizer getActionLocalizer()
        Returns:
        an action localizer that's suited for the current locale This implementation returns a PEActionLocalizer built from the same ResourceBundle as the one used for message internationalization.