0

如果 url 中没有指定,我正在尝试自动设置本地。

我想实现的是:

如果用户进入网站 www.example.com 会自动设置为英语。

我试过这个:

# homepage not localized: load the homepage with default language
index_not_localized:
   path:   /
   defaults:  { _controller: "AcmeSiteBundle:Default:index", _locale: en }


acme_site:
   resource: "@AcmeSiteBundle/Controller/"
   type:     annotation
   prefix:   /{_locale}
   defaults:  { _locale: en }
   requirements:
       _locale:  en|it

但如果我没有将语言放在 URL 中,则会出现此错误:

Unable to generate a URL for the named route "_demo" as such route does not exist.

我究竟做错了什么?

4

1 回答 1

0
Unable to generate a URL for the named route "_demo" as such route does not exist.

此异常意味着以下内容:

当您不将语言放在 URL 中时,它会转到控制器操作(通过路由)并在操作中的某处(可能是模板)尝试使用方法path或服务创建 URL urlrouter它会中断,因为您的Symfony 应用程序没有名为_demo.

于 2013-07-15T02:35:55.793 回答