@Singleton public class MessagesApi extends Object
Constructor and Description |
---|
MessagesApi(play.api.i18n.MessagesApi messages) |
Modifier and Type | Method and Description |
---|---|
play.api.i18n.MessagesApi |
asScala() |
Result |
clearLang(Result result)
Given a Result, return a new Result with the lang cookie discarded.
|
String |
get(play.api.i18n.Lang lang,
List<String> keys,
Object... args)
Translates the first defined message.
|
String |
get(play.api.i18n.Lang lang,
String key,
Object... args)
Translates a message.
|
Boolean |
isDefinedAt(play.api.i18n.Lang lang,
String key)
Check if a message key is defined.
|
boolean |
langCookieHttpOnly()
Whether the HTTP only attribute of the cookie should be set to true or not.
|
OptionalInt |
langCookieMaxAge()
An optional max age in seconds for the language Cookie.
|
String |
langCookieName()
Name for the language Cookie.
|
Optional<Http.Cookie.SameSite> |
langCookieSameSite()
The value of the [[SameSite]] attribute of the cookie.
|
boolean |
langCookieSecure()
Whether the secure attribute of the cookie is true or not.
|
Messages |
preferred(Collection<Lang> candidates)
Get a messages context appropriate for the given candidates.
|
Messages |
preferred(Http.RequestHeader request)
Get a messages context appropriate for the given request.
|
Result |
setLang(Result result,
Lang lang)
Given a Result and a Lang, return a new Result with the lang cookie set to the given Lang.
|
public play.api.i18n.MessagesApi asScala()
public String get(play.api.i18n.Lang lang, String key, Object... args)
Uses `java.text.MessageFormat` internally to format the message.
lang
- the message langkey
- the message keyargs
- the message argumentspublic String get(play.api.i18n.Lang lang, List<String> keys, Object... args)
Uses `java.text.MessageFormat` internally to format the message.
lang
- the message langkeys
- the messages keysargs
- the message argumentspublic Boolean isDefinedAt(play.api.i18n.Lang lang, String key)
lang
- the message langkey
- the message keypublic Messages preferred(Collection<Lang> 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.
candidates
- the candidate languagespublic Messages preferred(Http.RequestHeader request)
Will select a language from the request, based on the languages available, and fallback to the default language if none of the candidates are available.
request
- the incoming requestpublic Result setLang(Result result, Lang lang)
result
- the result where the lang will be set.lang
- the lang to set on the resultpublic Result clearLang(Result result)
result
- the result to clear the lang.public String langCookieName()
public OptionalInt langCookieMaxAge()
public boolean langCookieSecure()
public boolean langCookieHttpOnly()
public Optional<Http.Cookie.SameSite> langCookieSameSite()