sergeda
sergeda

Reputation: 2201

Play framework 2.4 internationalization and i18n.Messages - Scala

I follow documentation https://www.playframework.com/documentation/2.4.x/ScalaI18N and create this code to use i18n.Messages in view:

import play.api.data.Forms._
import play.api.i18n.I18nSupport
import play.i18n.MessagesApi

class Auth @Inject()(val messagesApi: MessagesApi) extends Controller with I18nSupport{
  val adminForm = Form(mapping(
    "login" -> nonEmptyText,
    "password" -> nonEmptyText)(Admin.apply)(Admin.unapply))

  def login = Action {
    implicit request =>
    Ok(views.html.admin.login(adminForm))
  }
}

With this I get compile error

overriding method messagesApi in trait I18nSupport of type => play.api.i18n.MessagesApi; value messagesApi has incompatible type

What I'm doing wrong?

Upvotes: 4

Views: 437

Answers (1)

grotrianster
grotrianster

Reputation: 2468

You mixing scala and java api's, the packages which start with play.api are reserved for Scala, import play.api.i18n.MessagesApi instead of play.i18n.MessagesApi.

Upvotes: 5

Related Questions