Package ej.nls

Interface NLS

  • All Known Implementing Classes:
    BinaryNLS

    public interface NLS
    NLS provides support for manipulating messages and languages.

    Each instance of a NLS manages a set of messages, and each message is defined by a unique ID (int value).

    Each language is defined by a locale string. By convention, a locale represents a specific geographical, political, or cultural region. It is often represented using the concatenation of a language code and a country code:

    • The language code is the lower-case, two-letter codes as defined by ISO-639.
    • The country code is the upper-case, two-letter codes as defined by ISO-3166.
    • Method Detail

      • getAvailableLocales

        String[] getAvailableLocales()
        Gets the list of available locales.
        Returns:
        the list of locales.
      • getDisplayName

        String getDisplayName​(String locale)
        Gets the human-readable name of the given locale.
        Parameters:
        locale - the locale.
        Returns:
        the human-readable name.
      • getMessage

        String getMessage​(int messageID,
                          int count)
        Gets the message or one of its plural forms matching an ID and a count value in the current language.

        The count argument is intended to be positive, negative values will however still be accepted and plugged into the plural expressions defined in the translations files.

        Parameters:
        messageID - the ID of the message to retrieve.
        count - the count value.
        Returns:
        the message at the specified ID in the corresponding plural form.
        Throws:
        ArrayIndexOutOfBoundsException - if the given messageID does not match a valid message.
      • getMessage

        String getMessage​(int messageID,
                          int count,
                          String locale)
        Gets the message or one of its plural forms matching an ID and a count value in a specific language.

        The count argument is intended to be positive, negative values will however still be accepted and plugged into the plural expressions defined in the translations files.

        Parameters:
        messageID - the ID of the message to retrieve.
        count - the count value.
        locale - the locale to use.
        Returns:
        the message at the specified ID in the corresponding plural form.
        Throws:
        ArrayIndexOutOfBoundsException - if the given messageID does not match a valid message.
      • getMessage

        String getMessage​(int messageID)
        Gets the message matching an ID in the current language.
        Parameters:
        messageID - the ID of the message to retrieve.
        Returns:
        the message at the specified ID.
        Throws:
        ArrayIndexOutOfBoundsException - if the given messageID does not match a valid message.
      • getMessage

        String getMessage​(int messageID,
                          String locale)
        Gets the message matching an ID in a specific language.
        Parameters:
        messageID - the ID of the message to retrieve.
        locale - the locale to use.
        Returns:
        the message at the specified ID.
        Throws:
        ArrayIndexOutOfBoundsException - if the given messageID does not match a valid message.
      • setCurrentLocale

        void setCurrentLocale​(String locale)
        Changes the current locale.
        Parameters:
        locale - the locale to set.
      • getCurrentLocale

        String getCurrentLocale()
        Gets the current locale.
        Returns:
        the current locale.