如果 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.
我究竟做错了什么?