Package org.nuiton.i18n
Class I18nStore
java.lang.Object
org.nuiton.i18n.I18nStore
public class I18nStore
extends java.lang.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 Summary
Fields Modifier and Type Field Description protected I18nBundle[]bundlesle cache de bundles deja chargesprotected java.util.LocaledefaultLocalela locale par defaut a utiliser.protected I18nLanguagelanguagele language actuellement utiliseprotected java.util.Map<java.util.Locale,I18nLanguage>languagesle cache de languages deja chargesprotected I18nInitializerresolverle resolver de bundles -
Constructor Summary
Constructors Constructor Description I18nStore(java.util.Locale defaultLocale, I18nInitializer resolver) -
Method Summary
Modifier and Type Method Description protected I18nLanguageaddLanguage(java.util.Locale locale)protected voidcheckInit()protected voidclose()Close store and release cache ofg language.I18nBundleEntry[]getBundleEntries()I18nBundleEntry[]getBundleEntries(java.util.Locale l)I18nBundle[]getBundles()I18nBundle[]getBundles(java.util.Locale l)I18nLanguagegetCurrentLanguage()Obtain the current language setted in the store.java.util.LocalegetCurrentLocale()Obtain the current locale setted in the store.java.util.LocalegetDefaultLocale()I18nLanguagegetLanguage()Deprecated.since 2.1, will be removed in version 3.0, prefer use now the methodgetCurrentLanguage().protected I18nLanguagegetLanguage(java.util.Locale locale)Recherche un object de typeI18nLanguagepour la locale donnée en paramètre dans le cache des langues chargées (languages).I18nLanguage[]getLanguages()protected java.util.Map<java.util.Locale,I18nLanguage>getLanguagesCache()java.util.Locale[]getLocales()I18nInitializergetResolver()protected voidinit()booleanisEmpty()protected booleanisInit()voidsetCurrentLocale(java.util.Locale locale)Sets the current locale for the store.protected voidsetLanguage(java.util.Locale locale)Deprecated.since 2.1, will be removed in version 3.0, use now the methodsetCurrentLocale(Locale).
-
Field Details
-
language
le language actuellement utilise -
languages
le cache de languages deja charges -
bundles
le cache de bundles deja charges -
defaultLocale
protected java.util.Locale defaultLocalela locale par defaut a utiliser. -
resolver
le resolver de bundles
-
-
Constructor Details
-
I18nStore
- Parameters:
defaultLocale- default localeresolver- resolver of bundles
-
-
Method Details
-
getCurrentLanguage
Obtain the current language setted in the store. This language is used for all translations without locale information (says the methodI18n.t(String, Object...)).- Returns:
- the current language or
nullif none is defined - Since:
- 2.1
-
getCurrentLocale
public java.util.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 methodI18n.t(String, Object...).- Returns:
- the current locale or
nullif no current language is setted - Since:
- 2.1
-
setCurrentLocale
public void setCurrentLocale(java.util.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.since 2.1, will be removed in version 3.0, prefer use now the methodgetCurrentLanguage().- Returns:
- current language loaded or null, if no language was load.
-
getLanguages
- Returns:
- le cache de language actuellement pris en charge.
-
getDefaultLocale
public java.util.Locale getDefaultLocale()- Returns:
- the default locale of the store
-
isEmpty
public boolean isEmpty() -
getLocales
public java.util.Locale[] getLocales()- Returns:
- array of all locales loaded
-
getBundles
-
getBundles
-
getBundleEntries
-
getBundleEntries
-
init
protected void init() -
setLanguage
@Deprecated protected void setLanguage(java.util.Locale locale)Deprecated.since 2.1, will be removed in version 3.0, use now the methodsetCurrentLocale(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
- Returns:
- le cache de language avec instanciation paresseuse
-
getLanguage
Recherche un object de typeI18nLanguagepour 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.
-
addLanguage
-
isInit
protected boolean isInit() -
checkInit
protected void checkInit() -
getResolver
-