user908853
user908853

Reputation:

value withLang is not a member of play.api.mvc.Result

In a Play Framework 2.3 app, I had the following method:

def defaultLanguage[T](f: => Lang => Request[T] => Result)
                      (implicit request: Request[T]) = {
  f(Lang(FRENCH))(request).withLang(Lang(FRENCH))
}

Worked great. Now that I am migrating to 2.4, I get the following error

value withLang is not a member of play.api.mvc.Result

I don't see anything about this in the migration manual, any idea on the equivalent of withLang in 2.4?

Upvotes: 0

Views: 471

Answers (1)

user1804599
user1804599

Reputation:

withLang is now in ResultWithLang. Mixin I18nSupport to get an implicit conversion:

class blabla with I18nSupport {
  def defaultLanguage[T](f: => Lang => Request[T] => Result)
                        (implicit request: Request[T]) =
    f(Lang(FRENCH))(request).withLang(Lang(FRENCH))
}

Upvotes: 1

Related Questions