DefaultMessagesApi

play.api.i18n.DefaultMessagesApi
@Singleton
class DefaultMessagesApi(val messages: Map[String, Map[String, String]], langs: Langs, val langCookieName: String, val langCookieSecure: Boolean, val langCookieHttpOnly: Boolean, val langCookieSameSite: Option[SameSite], val httpConfiguration: HttpConfiguration, val langCookieMaxAge: Option[Int]) extends MessagesApi

The Messages API.

Attributes

Graph
Supertypes
trait MessagesApi
class Object
trait Matchable
class Any

Members list

Value members

Constructors

def this(javaMessages: Map[String, Map[String, String]], langs: Langs)
def this(messages: Map[String, Map[String, String]])

Concrete methods

override def apply(key: String, args: Any*)(implicit lang: Lang): String

Translates a message.

Translates a message.

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

Value parameters

args

the message arguments

key

the message key

Attributes

Returns

the formatted message or a default rendering if the key wasn’t defined

Definition Classes
override def apply(keys: Seq[String], args: Any*)(implicit lang: Lang): String

Translates the first defined message.

Translates the first defined message.

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

Value parameters

args

the message arguments

keys

the message key

Attributes

Returns

the formatted message or a default rendering if the key wasn’t defined

Definition Classes
override def clearLang(result: Result): Result

Given a Result, return a new Result with the lang cookie discarded.

Given a Result, return a new Result with the lang cookie discarded.

Attributes

Definition Classes
override def isDefinedAt(key: String)(implicit lang: Lang): Boolean

Check if a message key is defined.

Check if a message key is defined.

Value parameters

key

the message key

Attributes

Returns

a boolean

Definition Classes
override def preferred(candidates: Seq[Lang]): Messages

Get the preferred messages for the given candidates.

Get the preferred messages for the given candidates.

Will select a language from the candidates, based on the languages available, and fallback to the default language if none of the candidates are available.

Attributes

Definition Classes
override def preferred(request: RequestHeader): Messages

Get the preferred messages for the given Java request

Get the preferred messages for the given Java request

Attributes

Definition Classes
override def preferred(request: RequestHeader): Messages

Get the preferred messages for the given request

Get the preferred messages for the given request

Attributes

Definition Classes
override def setLang(result: Result, lang: Lang): Result

Given a Result and a Lang, return a new Result with the lang cookie set to the given Lang.

Given a Result and a Lang, return a new Result with the lang cookie set to the given Lang.

Attributes

Definition Classes
override def translate(key: String, args: Seq[Any])(implicit lang: Lang): Option[String]

Translates a message.

Translates a message.

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

Value parameters

args

the message arguments

key

the message key

Attributes

Returns

the formatted message, if this key was defined

Definition Classes
override def withoutLang(result: Result): Result

Given a Result, return a new Result with the lang cookie discarded.

Given a Result, return a new Result with the lang cookie discarded.

Attributes

Definition Classes

Inherited methods

def asJava: MessagesApi

Attributes

Returns

The Java version for Messages API.

Inherited from:
MessagesApi

Concrete fields

Whether the HTTP only attribute of the cookie should be set to true or not.

Whether the HTTP only attribute of the cookie should be set to true or not.

Attributes

An optional max age in seconds for the language Cookie.

An optional max age in seconds for the language Cookie.

Attributes

Name for the language Cookie.

Name for the language Cookie.

Attributes

The value of the SameSite attribute of the cookie. If None, then no SameSite attribute is set.

The value of the SameSite attribute of the cookie. If None, then no SameSite attribute is set.

Attributes

Whether the secure attribute of the cookie is true or not.

Whether the secure attribute of the cookie is true or not.

Attributes

Get all the defined messages

Get all the defined messages

Attributes