Class DefaultI18N

  • All Implemented Interfaces:
    I18N

    public class DefaultI18N
    extends Object
    implements I18N
    • Method Detail

      • getInstance

        public static I18N getInstance()
        Get global instance (used in single-session mode)
        Returns:
        global instance
      • getInstance

        public static I18N getInstance​(String sessionId)
        Get instance for session
        Parameters:
        sessionId - session ID for multi-session mode, leave it null for global instance
        Returns:
        instance for session, or global instance
      • removeInstance

        public static I18N removeInstance​(String sessionId)
        Remove I18N instance for session
        Parameters:
        sessionId - session ID
        Returns:
        the previous value associated with sessionId, or null if there was no mapping for sessionId
      • getMessage

        public String getMessage​(String key)
        Description copied from interface: I18N
        Get the specified message in the default language (according to I18N.getDefaultLanguage()
        Specified by:
        getMessage in interface I18N
        Parameters:
        key - Key value
        Returns:
        Message for the given key, or null if none is found/available
      • getMessage

        public String getMessage​(String langCode,
                                 String key)
        Description copied from interface: I18N
        Get the specified message for the specified language
        Specified by:
        getMessage in interface I18N
        Parameters:
        langCode - ISO 639-1 language code: "en", "ja", etc
        key - Key value for the message to retrieve
        Returns:
        Message for the given key/language pair, or null if none is found
      • getDefaultLanguage

        public String getDefaultLanguage()
        Description copied from interface: I18N
        Get the currently set default language as an ISO 639-1 code
        Specified by:
        getDefaultLanguage in interface I18N
        Returns:
        The current default language
      • setDefaultLanguage

        public void setDefaultLanguage​(String langCode)
        Description copied from interface: I18N
        Set the default language
        Specified by:
        setDefaultLanguage in interface I18N
        Parameters:
        langCode - Language code, as an ISO 639-1 code
      • getMessages

        public Map<String,​String> getMessages​(String langCode)
        Description copied from interface: I18N
        Get all internationalization messages for the specified language code
        Specified by:
        getMessages in interface I18N
        Parameters:
        langCode - Language code
        Returns:
        Messages