Package org.nuiton.i18n
Class I18nLanguage
java.lang.Object
org.nuiton.i18n.I18nLanguage
public class I18nLanguage
extends java.lang.Object
Represents a language in i18n system with all his translations.
To obtain a translation, use the method
translate(String)- Since:
- 1.1
- Author:
- Tony Chemit - chemit@codelutin.com
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Localelocalela locale de la langueprotected booleanmissingKeyReturnNullUsed to know null should be returned when a key is not found.protected java.lang.StringrecordFilePathIndique le chemin du fichier dans lequel ecrire les entrees non trouveesprotected java.util.Propertiesresourcetoutes les traductions pour cette langue -
Constructor Summary
Constructors Constructor Description I18nLanguage(java.util.Locale l)I18nLanguage(java.util.Locale l, boolean missingKeyReturnNull)I18nLanguage(java.util.Locale locale, java.lang.String recordFilePath)I18nLanguage(java.util.Locale locale, java.lang.String recordFilePath, boolean missingKeyReturnNull) -
Method Summary
Modifier and Type Method Description voidclose()booleanequals(java.lang.Object o)protected voidfinalize()java.util.LocalegetLocale()inthashCode()booleanhasRecord(java.lang.String sentence)voidload(I18nBundleEntry[] bundleEntries)Deprecated.since 2.4 useload(I18nBundleEntry[], Charset)instead, charset must be provided to avoid encoding problemsvoidload(I18nBundleEntry[] bundleEntries, java.nio.charset.Charset encoding)charge les traductions de la languea partir d'une liste donnee de fichiers de traduction.protected voidrecordNotFound(java.lang.String key)intsize()java.lang.StringtoString()java.lang.Stringtranslate(java.lang.String sentence)Translate takes a sentence and returns its translation if found, the very same string otherwise.java.lang.Stringuntranslate(java.lang.String sentence)Untranslate takes a translated sentence and returns the original one if found, the very same string otherwise.
-
Field Details
-
resource
protected java.util.Properties resourcetoutes les traductions pour cette langue -
locale
protected final java.util.Locale localela locale de la langue -
recordFilePath
protected java.lang.String recordFilePathIndique le chemin du fichier dans lequel ecrire les entrees non trouvees -
missingKeyReturnNull
protected boolean missingKeyReturnNullUsed to know null should be returned when a key is not found.- Since:
- 2.4.1
-
-
Constructor Details
-
I18nLanguage
public I18nLanguage(java.util.Locale l) -
I18nLanguage
public I18nLanguage(java.util.Locale l, boolean missingKeyReturnNull) -
I18nLanguage
public I18nLanguage(java.util.Locale locale, java.lang.String recordFilePath) -
I18nLanguage
public I18nLanguage(java.util.Locale locale, java.lang.String recordFilePath, boolean missingKeyReturnNull)
-
-
Method Details
-
load
Deprecated.since 2.4 useload(I18nBundleEntry[], Charset)instead, charset must be provided to avoid encoding problemscharge les traductions de la languea partir d'une liste donnee de fichiers de traduction.- Parameters:
bundleEntries- the used bundles entries to load
-
load
charge les traductions de la languea partir d'une liste donnee de fichiers de traduction.- Parameters:
bundleEntries- the used bundles entries to loadencoding- Charset to use for Properties loading- Since:
- 2.4
-
translate
public java.lang.String translate(java.lang.String sentence)Translate takes a sentence and returns its translation if found, the very same string otherwise.- Parameters:
sentence- sentence to translate- Returns:
- translated sentence
-
recordNotFound
protected void recordNotFound(java.lang.String key) -
untranslate
public java.lang.String untranslate(java.lang.String sentence)Untranslate takes a translated sentence and returns the original one if found, the very same string otherwise.- Parameters:
sentence- sentence to untranslate- Returns:
- untranslated sentence
-
getLocale
public java.util.Locale getLocale() -
size
public int size() -
close
public void close() -
hasRecord
public boolean hasRecord(java.lang.String sentence) -
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-