Package play.i18n

Class MessagesImpl

  • All Implemented Interfaces:
    play.api.i18n.MessagesProvider, Messages

    public class MessagesImpl
    extends Object
    implements Messages
    This class implements the Messages interface.

    This class serves two purposes. One is for backwards compatibility, it serves the old static API for accessing messages. The other is a new API, which carries an inject messages, and a selected language.

    The methods for looking up messages on the old API are called get, on the new API, they are called at. In Play 3.0, when we remove the old API, we may alias the at methods to the get names.

    • Constructor Detail

      • MessagesImpl

        public MessagesImpl​(Lang lang,
                            MessagesApi messagesApi)
    • Method Detail

      • lang

        public Lang lang()
        Description copied from interface: Messages
        Get the lang for these messages.
        Specified by:
        lang in interface Messages
        Returns:
        the selected language for the messages.
      • messagesApi

        public MessagesApi messagesApi()
        Returns:
        The underlying API
      • at

        public String at​(String key,
                         Object... args)
        Get the message at the given key.

        Uses `java.text.MessageFormat` internally to format the message.

        Specified by:
        at in interface Messages
        Parameters:
        key - the message key
        args - the message arguments
        Returns:
        the formatted message or a default rendering if the key wasn't defined
      • at

        public String at​(List<String> keys,
                         Object... args)
        Get the message at the first defined key.

        Uses `java.text.MessageFormat` internally to format the message.

        Specified by:
        at in interface Messages
        Parameters:
        keys - the messages keys
        args - the message arguments
        Returns:
        the formatted message or a default rendering if the key wasn't defined
      • isDefinedAt

        public Boolean isDefinedAt​(String key)
        Check if a message key is defined.
        Specified by:
        isDefinedAt in interface Messages
        Parameters:
        key - the message key
        Returns:
        a Boolean
      • asScala

        public play.api.i18n.Messages asScala()
        Specified by:
        asScala in interface Messages