Package org.nuiton.i18n
Class I18nStore
- java.lang.Object
-
- org.nuiton.i18n.I18nStore
-
public class I18nStore extends Object
Represents the store of languages of the i18n system. Replace theorg.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[]
bundles
le cache de bundles deja chargesprotected Locale
defaultLocale
la locale par defaut a utiliser.protected I18nLanguage
language
le language actuellement utiliseprotected Map<Locale,I18nLanguage>
languages
le cache de languages deja chargesprotected I18nInitializer
resolver
le resolver de bundles
-
Constructor Summary
Constructors Constructor Description I18nStore(Locale defaultLocale, I18nInitializer resolver)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected I18nLanguage
addLanguage(Locale locale)
protected void
checkInit()
protected void
close()
Close store and release cache ofg language.I18nBundleEntry[]
getBundleEntries()
I18nBundleEntry[]
getBundleEntries(Locale l)
I18nBundle[]
getBundles()
I18nBundle[]
getBundles(Locale l)
I18nLanguage
getCurrentLanguage()
Obtain the current language setted in the store.Locale
getCurrentLocale()
Obtain the current locale setted in the store.Locale
getDefaultLocale()
I18nLanguage
getLanguage()
Deprecated.since 2.1, will be removed in version 3.0, prefer use now the methodgetCurrentLanguage()
.protected I18nLanguage
getLanguage(Locale locale)
Recherche un object de typeI18nLanguage
pour la locale donnée en paramètre dans le cache des langues chargées (languages
).I18nLanguage[]
getLanguages()
protected Map<Locale,I18nLanguage>
getLanguagesCache()
Locale[]
getLocales()
I18nInitializer
getResolver()
protected void
init()
boolean
isEmpty()
protected boolean
isInit()
void
setCurrentLocale(Locale locale)
Sets the current locale for the store.protected void
setLanguage(Locale locale)
Deprecated.since 2.1, will be removed in version 3.0, use now the methodsetCurrentLocale(Locale)
.
-
-
-
Field Detail
-
language
protected I18nLanguage language
le language actuellement utilise
-
languages
protected Map<Locale,I18nLanguage> languages
le cache de languages deja charges
-
bundles
protected I18nBundle[] bundles
le cache de bundles deja charges
-
defaultLocale
protected Locale defaultLocale
la locale par defaut a utiliser.
-
resolver
protected I18nInitializer resolver
le resolver de bundles
-
-
Constructor Detail
-
I18nStore
public I18nStore(Locale defaultLocale, I18nInitializer resolver)
- Parameters:
defaultLocale
- default localeresolver
- 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 methodI18n.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 methodI18n.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 methodgetCurrentLanguage()
.- 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
-
getBundles
public I18nBundle[] getBundles()
-
getBundles
public I18nBundle[] getBundles(Locale l)
-
getBundleEntries
public I18nBundleEntry[] getBundleEntries()
-
getBundleEntries
public I18nBundleEntry[] getBundleEntries(Locale l)
-
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 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
protected Map<Locale,I18nLanguage> getLanguagesCache()
- Returns:
- le cache de language avec instanciation paresseuse
-
getLanguage
protected I18nLanguage getLanguage(Locale locale)
Recherche un object de typeI18nLanguage
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.
-
addLanguage
protected I18nLanguage addLanguage(Locale locale)
-
isInit
protected boolean isInit()
-
checkInit
protected void checkInit()
-
getResolver
public I18nInitializer getResolver()
-
-