All the messages of the application, as a map of (lang -> map(key -> message pattern)). As it
is the case in Play, JsMessages assumes that “default” messages are indexed by the "default"
and "default.play" language codes.
Generates a JavaScript function computing localized messages in all the languages of the application.
Generates a JavaScript function computing localized messages in all the languages of the application.
For example:
val messages = Action { Ok(jsMessages.all(Some("window.Messages"))) }
Then use it in your JavaScript code as follows:
alert(Messages('en', 'greeting', 'World'));
Provided you have the following message in your conf/messages file:
greeting=Hello {0}!Note that, given a message key, the JavaScript function will search the corresponding message in the
following locations, in order: the language (e.g. in the conf/messages.fr-FR file), the language
country (e.g. conf/messages.fr), the application default messages (conf/messages) and the
Play default messages.
Note: This implementation does not handle quotes escaping in patterns and subformats (see http://docs.oracle.com/javase/7/docs/api/java/text/MessageFormat.html)
Optional JavaScript namespace to use to put the function definition. If not set, this
function will just generate a function. Otherwise it will generate a function and
assign it to the given namespace. Note: you can set something like
Some("var Messages") to use a fresh variable.
Messages for each available lang of the application.
Messages for each available lang of the application.
The message corresponding to a given key is found by searching in the
following locations, in order: the language (e.g. in the conf/messages.fr-FR file), the language
country (e.g. conf/messages.fr), the application default messages (conf/messages) and the
Play default messages.
Same as allMessages, but as a JSON value.
Generates a JavaScript function computing localized messages in the given implicit Lang.
Generates a JavaScript function computing localized messages in the given implicit Lang.
For example:
val messages = Action { implicit request => Ok(jsMessages(Some("window.Messages"))) }
Then use it in your JavaScript code as follows:
alert(Messages('greeting', 'World'));Provided you have the following message in your conf/messages file:
greeting=Hello {0}!Note: This implementation does not handle quotes escaping in patterns and subformats (see http://docs.oracle.com/javase/7/docs/api/java/text/MessageFormat.html)
Optional JavaScript namespace to use to put the function definition. If not set, this
function will just generate a function. Otherwise it will generate a function and assign
it to the given namespace. Note: you can set something like Some("var Messages") to use
a fresh variable.
Messages instance defining the language to use. The message corresponding to a given key is found by searching in the
following locations, in order: the language (e.g. in the conf/messages.fr-FR file), the language
country (e.g. conf/messages.fr), the application default messages (conf/messages) and the
Play default messages.
Messages instance containing the lang to retrieve messages for
The messages defined for the given language lang, as a map
of (key -> message). The message corresponding to a given key is found by searching in the
following locations, in order: the language (e.g. in the conf/messages.fr-FR file), the language
country (e.g. conf/messages.fr), the application default messages (conf/messages) and the
Play default messages.
Messages instance containing the lang to retrieve messages for
The JSON formatted string of the for the given language lang. This is strictly equivalent to
Json.toJson(jsMessages.messages).toString, but may be faster due to the use of caching.
Generate a JavaScript function computing localized messages of a Play application.
Typical usage (from within a Play controller):
Then on client-side:
See JsMessagesFactory to know how to get a
JsMessagesinstance.