Play 2.6 I18N API Migration not working

122 views
Skip to first unread message

Emmanuel

unread,
Jun 28, 2017, 3:36:59 AM6/28/17
to Play Framework
Hello,

I am trying to migrate an existing application to Play 2.6, but fails to do so. If I try to start from scratch from the documentation and use this piece of code:

import javax.inject.Inject
import play.api.i18n._

class MySupportController @Inject()(val controllerComponents: ControllerComponents)
  extends BaseController
    with I18nSupport {

def messages2 = Action { implicit request =>
    // type enrichment through I18nSupport
    val lang: Lang = request.lang
    val message: String = messagesApi("info.error")(lang)
    Ok(message)
  }
}

I get a: value lang is not a member of type parameter R[B]


Any idea ?

Will Sargent

unread,
Jun 28, 2017, 11:11:00 AM6/28/17
to play-fr...@googlegroups.com
I haven't had coffee yet, but I think this might be one of the deprecated implicits:


request.lang should be defined as an implicit conversion from the low priority trait here:


You can always say request.messages.lang in a pinch.


--
Will Sargent
Engineer, Lightbend, Inc.


--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/1cfe4ac5-c363-49ce-a861-5f61abf66c63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Emmanuel

unread,
Jun 29, 2017, 2:14:10 AM6/29/17
to Play Framework
You are right, it works fine with request.messages.lang. Does that mean the doc (https://playframework.com/documentation/2.6.x/ScalaI18N) is not up to date?
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages