Reputation:
I am trying to follow this:
Basic tutorial to learn about the Play framework. I receive an error message on this line:
@inputText(taskForm("label"))
Where the error message is this:
could not find implicit value for parameter messages: play.api.i18n.Messages
I render this view in my controller like this:
def tasks = Action {
Ok(views.html.index(Task.all(), taskForm))
}
I've Googled the error message and it seems the implicit message is for internationalizing strings, but I've yet to find a post on how to actually fix this error and I'm also confused because this is an official tutorial, and the code doesn't compile.
Upvotes: 2
Views: 1316
Reputation: 1061
I know this question is old, but I had the same problem trying to go through the tutorial with Play 2.6.x, and resolved it by following the instructions at https://stackoverflow.com/a/30800825/1033203, except that instead of using:
(implicit messages: Messages)
in my view signature, I needed:
(implicit messagesProvider: MessagesProvider)
Upvotes: 0
Reputation: 111
You can pass implicit request in the action and implicit play.api.i18n.Messages in the template.
@(tasks: List[Task], taskForm: Form[String])(implicit messages: play.api.i18n.Messages)
Upvotes: 0
Reputation: 438
Try using an implicit request
in the Action
, and put an implicit lang
at the top of the template.
def tasks = Action { implicit request =>
Ok(views.html.index(Task.all(), taskForm))
}
And at the top of the index template:
@(tasks: List[Task], taskForm: Form[String])(implicit lang: Lang)
The request
provides the Lang
for the template.
Upvotes: 2