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.Locale locale
    la locale de la langue
    protected boolean missingKeyReturnNull
    Used to know null should be returned when a key is not found.
    protected java.lang.String recordFilePath
    Indique le chemin du fichier dans lequel ecrire les entrees non trouvees
    protected java.util.Properties resource
    toutes 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
    void close()  
    boolean equals​(java.lang.Object o)  
    protected void finalize()  
    java.util.Locale getLocale()  
    int hashCode()  
    boolean hasRecord​(java.lang.String sentence)  
    void load​(I18nBundleEntry[] bundleEntries)
    Deprecated.
    since 2.4 use load(I18nBundleEntry[], Charset) instead, charset must be provided to avoid encoding problems
    void load​(I18nBundleEntry[] bundleEntries, java.nio.charset.Charset encoding)
    charge les traductions de la languea partir d'une liste donnee de fichiers de traduction.
    protected void recordNotFound​(java.lang.String key)  
    int size()  
    java.lang.String toString()  
    java.lang.String translate​(java.lang.String sentence)
    Translate takes a sentence and returns its translation if found, the very same string otherwise.
    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.

    Methods inherited from class java.lang.Object

    clone, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • resource

      protected java.util.Properties resource
      toutes les traductions pour cette langue
    • locale

      protected final java.util.Locale locale
      la locale de la langue
    • recordFilePath

      protected java.lang.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​(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 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, java.nio.charset.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 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:
      finalize in class java.lang.Object
      Throws:
      java.lang.Throwable
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

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

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object