I18n Playframework 2.4 does not work [Fixed]

I have 2 problems. One of them is related to scala code, and the other to html. I am trying to translate my site into Dutch and English. When my browser has Dutch as the preferred language, it displays the site in Dutch. But if I have English as my preferred language, it also displays the site in Dutch.

application.conf

play.i18n.langs = [ "en", "nl" ]

messages.en

login.title=Login
error.required=Field is required.
error.email.required=A valid email adress is required.

messages.nl

login.title=Inloggen
error.required=Dit veld is verplicht.
error.email.required=Een geldig e-mailadres is vereist.

Debug LogIn.scala

import play.api.i18n.Messages.Implicits._

object LogIn extends Controller{

val logInForm = Form(mapping(
"email" -> text.verifying(Messages("error.email.required"), {_.contains('@')}),
"password" -> text.verifying(Messages("error.required"), {!_.isEmpty})
))
}

How am I wrong? How can I display my site in English

Another problem is with html. The playframework website says & {'key'}, but that doesn't seem to work.

<h1 class="title">&{'login.title'}</h1>

"& {'Login.title'}" is displayed, not "Login" or "Inloggen" How does html read message files?

UPDATE: , & {'login.title'} :

@import play.i18n._

<h1>@Messages.get("login.title")</h1>

, ,

Intellij scala, Play Framework 2.4 - .

UPDATE2: , , , . , . : 3

+4

Source: https://habr.com/ru/post/1605736/


All Articles