Ambiguous values in Lang and requestLang

爱⌒轻易说出口 提交于 2019-12-24 02:18:48

问题


Using: PlayFramework 2.3 and SecureSocial (compatible version with 2.3)

Im receiving this error in the ViewTemplate:

[error] /Users/einevea/projects/einjar/einevault/econcepts/modules/eusers/app/services.eusers/MyViewTemplates.scala:29: ambiguous implicit values:
[error]  both method request2lang in trait Controller of type (implicit request: play.api.mvc.RequestHeader)play.api.i18n.Lang
[error]  and value lang of type play.api.i18n.Lang
[error]  match expected type play.api.i18n.Lang
[error]   override def getStartSignUpPage(form: Form[String])(implicit request: RequestHeader, lang: Lang): Html = views.html.eusers.custom.startSignUp(WUPage(Messages("securesocial.signup.title")),form)(request, lang, env)

Any help?


回答1:


The error message means that you have tried to call getStartSignUpPage and that takes an implicit play.api.i18n.Lang but there are two implicit Lang instances in your scope, so therefore the compiler does not know which one to choose.

The first one is the value lang which you have imported or defined (either as a value in the template or as an implicit parameter in the parameter lists of the template)

The second one is a built in one that comes from play Controller.request2Lang which knows how to extract Lang from the request to select the language that the browser said that it accepts (in the Accept-Language header).

You could work around this in a few ways: avoid having two Lang instances in scope, provide the parameters explicitly where you call getStartSignUpPage or make the implicit parameter list a regular parameter list.



来源:https://stackoverflow.com/questions/26200820/ambiguous-values-in-lang-and-requestlang

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!