Module aeonics.core

Class Translator

  • All Implemented Interfaces:
    Exportable, Snapshotable

    public abstract class Translator
    extends Manager.Type
    Manages the translation of text intented for end-users. The availability of any language depends on the implementation, however it is recommended to always provide english ('en') as a fallback.
    • Constructor Detail

      • Translator

        public Translator()
    • Method Detail

      • manager

        public final java.lang.Class<? extends Manager.Type> manager()
        Hardcoded manager type
        Specified by:
        manager in class Manager.Type
        Returns:
        the type of manager
      • language

        public abstract void language​(java.lang.String language)
        Sets the default language
        Parameters:
        language - the ISO-639 (2 letter) language code
      • language

        public abstract java.lang.String language()
        Returns the current default language
        Returns:
        the current default language
      • get

        public java.lang.String get​(java.lang.String key)
        Gets the translation of the specified key in the default language.
        Parameters:
        key - the translation key
        Returns:
        the translated text
        See Also:
        language()
      • get

        public abstract java.lang.String get​(java.lang.String key,
                                             java.lang.String language)
        Gets the translation of the specified key in the specified language. The implementation may return the translated value in the default language if the translation does not exist in the specified language.
        Parameters:
        key - the translation key
        language - the ISO-639 (2 letter) language code
        Returns:
        the translated text
      • set

        public abstract void set​(java.lang.String key,
                                 java.lang.String text,
                                 java.lang.String language)
        Sets the translation of the specified key in the specified language.
        Parameters:
        key - the translation key
        text - the translated text
        language - the ISO-639 (2 letter) language code
      • set

        public void set​(Data keys,
                        java.lang.String language)
        Sets the translation of the specified keys in the specified language.
        Parameters:
        keys - the translated key-value pairs
        language - the ISO-639 (2 letter) language code
      • clear

        public abstract void clear​(java.lang.String language)
        Clears all translations in the specified language
        Parameters:
        language - the ISO-639 (2 letter) language code
      • clear

        public abstract void clear()
        Clears all translations in all languages