Class I18nLanguage

java.lang.Object
org.nuiton.i18n.I18nLanguage

public class I18nLanguage extends 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 Details

    • resource

      protected Properties resource
      toutes les traductions pour cette langue
    • locale

      protected final Locale locale
      la locale de la langue
    • recordFilePath

      protected String recordFilePath
      Indique le chemin du fichier dans lequel ecrire les entrees non trouvees
    • missingKeyReturnNull

      protected boolean missingKeyReturnNull
      Used to know null should be returned when a key is not found.
      Since:
      2.4.1
  • Constructor Details

    • I18nLanguage

      public I18nLanguage(Locale l)
    • I18nLanguage

      public I18nLanguage(Locale l, boolean missingKeyReturnNull)
    • I18nLanguage

      public I18nLanguage(Locale locale, String recordFilePath)
    • I18nLanguage

      public I18nLanguage(Locale locale, String recordFilePath, boolean missingKeyReturnNull)
  • Method Details

    • load

      @Deprecated public void load(I18nBundleEntry[] bundleEntries)
      Deprecated.
      since 2.4 use load(I18nBundleEntry[], Charset) instead, charset must be provided to avoid encoding problems
      charge les traductions de la languea partir d'une liste donnee de fichiers de traduction.
      Parameters:
      bundleEntries - the used bundles entries to load
    • load

      public void load(I18nBundleEntry[] bundleEntries, Charset encoding)
      charge les traductions de la languea partir d'une liste donnee de fichiers de traduction.
      Parameters:
      bundleEntries - the used bundles entries to load
      encoding - Charset to use for Properties loading
      Since:
      2.4
    • translate

      public String translate(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(String key)
    • untranslate

      public String untranslate(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 Locale getLocale()
    • size

      public int size()
    • close

      public void close()
    • hasRecord

      public boolean hasRecord(String sentence)
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object