Reputation: 1
I am working on migrating my project from play 2.5 to 2.6. Everything seems ok, however, there is a problem with i18n in within my views, rendered by scala controllers(and there is no such problem with java controllers).
To provide i18n, play.api.i18n.Messages.apply
method is used in both cases, but with Scala controller(derived from AbstractController
or InjectedController
) there are only marks from Messages.lang
file, not values.
How can I resolve this?
Upvotes: 0
Views: 60
Reputation: 1799
In your controller
class:
Extending it with AbstractController
and I18nSupport
:
class myController @Inject()
(controllerComponents: ControllerComponents,actorSystem: ActorSystem)
(implicit assetsFinder: AssetsFinder)
extends AbstractController(cc) with I18nSupport{
??? //Body of your controller class.
}
In your views
:
Within your views file use three implicit values of RequestHeader
, Messages
, and AssetsFinder
:
@(whatever: Any)(implicit req: RequestHeader, messages: Messages, assetsFinder: AssetsFinder)
Upvotes: 1