Class I18nStore


  • public class I18nStore
    extends Object
    Represents the store of languages of the i18n system. Replace the org.nuiton.i18n.I18nLoader class from project http://maven-site.nuiton.org/nuiton-utils
    Since:
    1.1
    Author:
    Tony Chemit - chemit@codelutin.com
    • Field Detail

      • language

        protected I18nLanguage language
        le language actuellement utilise
      • bundles

        protected I18nBundle[] bundles
        le cache de bundles deja charges
      • defaultLocale

        protected Locale defaultLocale
        la locale par defaut a utiliser.
    • Constructor Detail

      • I18nStore

        public I18nStore​(Locale defaultLocale,
                         I18nInitializer resolver)
        Parameters:
        defaultLocale - default locale
        resolver - resolver of bundles
    • Method Detail

      • getCurrentLanguage

        public I18nLanguage getCurrentLanguage()
        Obtain the current language setted in the store. This language is used for all translations without locale information (says the method I18n.t(String, Object...)).
        Returns:
        the current language or null if none is defined
        Since:
        2.1
      • getCurrentLocale

        public Locale getCurrentLocale()
        Obtain the current locale setted in the store. This locale is coming from the current language and is used for all translations without locale information (says the method I18n.t(String, Object...).
        Returns:
        the current locale or null if no current language is setted
        Since:
        2.1
      • setCurrentLocale

        public void setCurrentLocale​(Locale locale)
        Sets the current locale for the store. This will set the current language with this given locale.
        Parameters:
        locale - the new current locale
        Since:
        2.1
      • getLanguage

        @Deprecated
        public I18nLanguage getLanguage()
        Deprecated.
        since 2.1, will be removed in version 3.0, prefer use now the method getCurrentLanguage().
        Returns:
        current language loaded or null, if no language was load.
      • getLanguages

        public I18nLanguage[] getLanguages()
        Returns:
        le cache de language actuellement pris en charge.
      • getDefaultLocale

        public Locale getDefaultLocale()
        Returns:
        the default locale of the store
      • isEmpty

        public boolean isEmpty()
      • getLocales

        public Locale[] getLocales()
        Returns:
        array of all locales loaded
      • init

        protected void init()
      • setLanguage

        @Deprecated
        protected void setLanguage​(Locale locale)
        Deprecated.
        since 2.1, will be removed in version 3.0, use now the method setCurrentLocale(Locale).
        Set a new language in store, given a locale.
        Parameters:
        locale - la locale du language requis
      • close

        protected void close()
        Close store and release cache ofg language. Current language will be also cleaned.
      • getLanguagesCache

        protected Map<Locale,​I18nLanguage> getLanguagesCache()
        Returns:
        le cache de language avec instanciation paresseuse
      • getLanguage

        protected I18nLanguage getLanguage​(Locale locale)
        Recherche un object de type I18nLanguage pour la locale donnée en paramètre dans le cache des langues chargées (languages). Si un tel objet n'existe pas, alors on en crée un et on le place dans le cache.
        Parameters:
        locale - la locale du language recherche
        Returns:
        le language trouve dans le cache.
      • isInit

        protected boolean isInit()
      • checkInit

        protected void checkInit()