|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.i18n.I18n
public class I18n
New generation I18n class.
Note: This class replace the previous one in projectnuiton-utils.
This class is a facility for internationalization. To use it in your soft,
you can either :
| Field Summary | |
|---|---|
static String |
DEFAULT_ENCODING
|
static Locale |
DEFAULT_LOCALE
|
protected static I18nFilter |
filter
Filtre a appliquer avant de retourner les chaines |
protected static I18nInitializer |
initializer
I18n initializer |
static String |
ISO_8859_1_ENCONDING
|
protected static I18nStore |
store
I18n store of languages |
static String |
UTF_8_ENCONDING
|
| Constructor Summary | |
|---|---|
I18n()
|
|
| Method Summary | |
|---|---|
static String |
_(String message)
Retourne la chaine traduite si possible. |
static String |
_(String message,
Object... args)
Retourne la chaine traduite si possible. |
protected static String |
applyFilter(String message)
Applique le filtre s'il y en a un |
static void |
close()
close i18n caches, says the store if exists This method should be called to reset all caches (languages, bundles,...) |
protected static I18nLanguage |
getCurrentLanguage()
|
protected static I18nFilter |
getFilter()
|
static I18nInitializer |
getInitializer()
|
static I18nStore |
getLoader()
Deprecated. since 1.1, only keep for compatibility |
static I18nStore |
getStore()
Get the i18n store. |
static void |
init()
Initialise la librairie avec encoding par defaut et locale par defaut |
static void |
init(Locale locale)
Initialize the library for given locale with DEFAULT_ENCODING. |
static void |
init(String language,
String country)
Initialise la librairie |
static String |
n_(String message)
Retourne la chaine passé en argument. |
static String |
n_(String message,
Object... args)
Retourne la chaine passée en argument. |
static Locale |
newLocale(String str)
Deprecated. since 1.1, prefer use the I18nUtil.newLocale(String) |
static Locale |
newLocale(String language,
String country)
Deprecated. since 1.1, prefer use the I18nUtil.newLocale(String,String) |
static Locale[] |
parseLocales(String str)
Deprecated. since 1.1, prefer use the I18nUtil.parseLocales(String) |
static void |
setFilter(I18nFilter filter)
Change le filtre des chaines traduites |
static void |
setInitializer(I18nInitializer initializer)
Sets the initializer to use to init the I18n system. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ISO_8859_1_ENCONDING
public static final String UTF_8_ENCONDING
public static final String DEFAULT_ENCODING
public static final Locale DEFAULT_LOCALE
protected static I18nInitializer initializer
protected static I18nStore store
protected static I18nFilter filter
| Constructor Detail |
|---|
public I18n()
| Method Detail |
|---|
public static void setInitializer(I18nInitializer initializer)
init(XXX).
initializer - the initializer to set.DefaultI18nInitializerpublic static void setFilter(I18nFilter filter)
filter - l'objet filtre a utiliserpublic static void init()
public static void init(String language,
String country)
language - une chaine representant la langue à utiliser fr, en, ...country - une chaine representant le pays à utiliser FR, GB, ...public static void init(Locale locale)
locale with DEFAULT_ENCODING.
locale - language to usepublic static String _(String message)
message - la chaine a traduire
public static String _(String message,
Object... args)
message - message formate avec la meme syntaxe que String.format(java.lang.String, java.lang.Object...)args - les parametres pour le message.
public static String n_(String message,
Object... args)
String key = "nuitonutils.key"; String result = _(key)fonctionnera, mais la chaine n'aura pas été marquée comme devant être internationalisé. Tres utile par exemple, pour crée des objets non internationnalisé, et devant être traduit seulement à leur lecture suivant la locale du lecteur et non du créateur.
message - message formate avec la meme syntaxe que String.format(String, Object...)args - les parametres pour le message.
public static String n_(String message)
String key = "nuitonutils.key"; String result = _(key)fonctionnera, mais la chaine n'aura pas été marquée comme devant être internationalisé. Tres utile par exemple, pour crée des objets non internationnalisé, et devant être traduit seulement à leur lecture suivant la locale du lecteur et non du créateur.
message - la chaine à traduire
public static void close()
public static I18nInitializer getInitializer()
public static I18nStore getStore()
protected static String applyFilter(String message)
message - le message qui devrait etre retourne avant application du
filtre.
protected static I18nLanguage getCurrentLanguage()
null if store is
not init.protected static I18nFilter getFilter()
@Deprecated public static I18nStore getLoader()
@Deprecated
public static Locale[] parseLocales(String str)
throws IllegalArgumentException
I18nUtil.parseLocales(String)
Locale seperated by comma.
Example : fr_FR,en_GB
str - the string representation of locale separated by comma
IllegalArgumentException - ia a locale is not valid@Deprecated public static Locale newLocale(String str)
I18nUtil.newLocale(String)
str - the text representation of the locale
@Deprecated
public static Locale newLocale(String language,
String country)
I18nUtil.newLocale(String,String)
language - the language of the localecountry - the country of the locale
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||