Scala Playframework:找不到参数消息的隐含值:play.api.i18n.Messages

时间:2017-01-10 21:02:22

标签: scala playframework

我对Play框架非常陌生。我是在Play for Scala的书上工作的。自从Play继续前进之后,它有点过时了。我试图让@Messages在我的一个观点中工作,但遇到了麻烦,我在标题栏/我发布的图片中收到了错误。enter image description here

这是我试图展示的观点。

@(title: String)(content: Html)(implicit lang: Lang) @()(implicit Messages: Messages).
<!DOCTYPE html>
<html>
   <head>
      <title>@title</title>
      <link rel="stylesheet" type="text/css" media="screen"
         href='@routes.Assets.versioned("stylesheets/bootstrap.css")'>
      <link rel="stylesheet" media="screen"
      href="@routes.Assets.versioned("stylesheets/main.css")">
   </head>
   <body>
      <div class="screenshot">
         <div class="navbar navbar-fixed-top">
            <div class="navbar-inner">
               <div class="container">
                  <a class="brand" href="@routes.HomeController.index()">
                  @Messages("application.name") <!--this is the error I get in the title-->
                  </a>
               </div>
            </div>
         </div>
         <div class="container">
            @content
         </div>
      </div>
   </body>
</html>

我有两个控制器几乎都做同样的事情。 这是第一个。

package controllers
import play.api.mvc.{Action,Controller}
import models.Product
import javax.inject.Inject
import play.api.i18n._

class Products @Inject()(val messagesApi: MessagesApi) extends Controller with I18nSupport {
  def list = Action { implicit request =>
    val products = Product.findAll
    Ok(views.html.products.list(products))
  }
}

这是第二个:

package controllers
import javax.inject._
import play.api._
import play.api.mvc._

@Singleton
class HomeController @Inject() extends Controller {
  def index = Action { implicit request =>
    Redirect(routes.Products.list())
  }
}

这是路线

# Routes
# This file defines all application routes (Higher priority routes first)
# https://www.playframework.com/documentation/latest/ScalaRouting
# ~~~~

# An example controller showing a sample home page
GET     /                           controllers.HomeController.index

# Map static resources from the /public folder to the /assets URL path
GET     /assets/*file               controllers.Assets.versioned(path="/public", file: Asset)

GET /products controllers.Products.list

这是消息文件:

    # https://www.playframework.com/documentation/latest/ScalaI18N

application.name = Product catalog

我真的被困在这里了。任何帮助表示赞赏。

0 个答案:

没有答案