Reputation: 3204
I am trying to use internationalization in twirl templates. I followed this guide: https://stackoverflow.com/a/30800825/1567737
I am having issues with the implicit messages: Messages
. I have reduced my setup to the bare minimum on which the error occurs:
import javax.inject.Inject
import play.api.i18n.{I18nSupport, MessagesApi}
import play.api.mvc.{Action, Controller}
class TestController @Inject()(val messagesApi: MessagesApi)
extends Controller with I18nSupport {
def index = Action {
Ok(views.html.test.render())
}
}
test.scala.html
@()(implicit messages: Messages)
I have also added routesGenerator := InjectedRoutesGenerator
to my build.sbt.
This should be sufficient according to the docs and the guide I linked above. Still I get the following compile time error:
[error] app/controllers/TestController.scala:11: not enough arguments for method render: (messages: play.api.i18n.Messages)play.twirl.api.HtmlFormat.Appendable.
[error] Unspecified value parameter messages.
[error] Ok(views.html.test.render())
Upvotes: 1
Views: 854
Reputation: 3204
Well, apparently implicit parameters only work on the apply
method. And not when you explicitly call render
.
Ok(views.html.test.render())
Must be
Ok(views.html.test())
Upvotes: 1