This question builds upon a case I found here
index.scala.html
@(text: String)(implicit messages: Messages)
@main("Fancy title") {
<h1>@messages("header.index")</h1>
<div>@text</div>
}
main.scala.html
@(title: String)(content: Html)(implicit messages: Messages)
<html>
<head>
<title>@title</title>
</head>
<body>
<h1>@messages("header.main")</h1>
@content
<body>
</html>
In this example I have index calling main and I would like both to access messages.
The compiler gives me "could not find implicit value for parameter messages: play.api.i18n.Messages" inside of index but if I remove the implicit parameter declaration from main then index works fine and gets the message. It seems like the compiler is telling me that it doesn't know how to pass the implicit parameter down the line.
Before trying with workarounds I would like to understand why this doesn't work.
In Play 2.4 you need to Inject MessageAPI in your controller and call preferred menu in your action to create message. if you define it as implicit in your action. Then everything will work.