[Play 2.5 - JAVA] Template view - @Messages.get deprecated

545 views
Skip to first unread message

Thibault Meyer

unread,
Mar 24, 2016, 2:20:24 AM3/24/16
to play-framework
Hi,

it seems that

@Messages.get("msg.key")

and 

@Messages.get(lang(), "msg.key")

was deprecated and the new methods "at" was not static and don't let force a language (usefull when sending email in the recipient language and not the current language on the browser)

what the new way to proceed with internationalization ? Is an instance of Play.i18n.Message or Play.api.i18n.Messag will be implicitelly available (like lang(), request(), ...) ?

Naftoli Gugenheim

unread,
Mar 24, 2016, 7:10:43 PM3/24/16
to play-framework

You have to add it as a (possibly implicit) parameter to your template, for starters.


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/2a097087-e46c-4ec5-bb46-b978008b24cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tom Pawlak

unread,
Mar 29, 2016, 6:20:50 AM3/29/16
to play-framework
Hi,

As it is detailed at: https://www.playframework.com/documentation/2.5.x/JavaI18N, you can use the Scala Messages object from within templates e.g. @Messages("msg.key")

That works with the latest changes for Play framework 2.4 and 2.5

Thibault Meyer

unread,
Apr 7, 2016, 3:17:26 AM4/7/16
to play-framework
Hi Tom, 

but it seem to have an issue with the Scala version.


By example, when we render a form field error


with play.i18n.Messages

@Messages.get(emailManagerVerifyForm.error("verifyCode").message, emailManagerVerifyForm.error("verifyCode").arguments)

Output : Maximum length is 20


with play.api.i18n.Messages

@Messages(emailManagerVerifyForm.error("verifyCode").message, emailManagerVerifyForm.error("verifyCode").arguments)

Output : Maximum length is [20]

Why [ and ] are printed ?
Reply all
Reply to author
Forward
0 new messages