MessagesApi

play.api.i18n.MessagesApi
trait MessagesApi

The internationalisation API.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

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

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

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

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

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

Get the preferred messages for the given request

Get the preferred messages for the given request

Attributes

def preferred(request: RequestHeader): Messages

Get the preferred messages for the given Java request

Get the preferred messages for the given Java request

Attributes

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

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

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

Concrete methods

def asJava: MessagesApi

Attributes

Returns

The Java version for Messages API.

Deprecated methods

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

Deprecated
true