0

I'm trying to get this setup but I'm having problems: use lunetics locale bundle.

the user accesses the site www.example.com, the bundle takes the user's locale and displays the page with its local, for example, if his place is the German you will see www.example.com/de.

This configuration can not seem to get it.

The strange thing is that I get strange behavior with the routes even without that bundle: For example I set this route:

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

if I go to www.example.com/en page is displayed

if I go to www.example.com I returned an error where it says that there is no route /.

What am I doing wrong?

4

1 回答 1

0

我不确定您的控制器文件夹是什么样的,但我能够使用 AcmeDemoBundle WelcomeController 解决您的问题,如下所示:

acme_site_default:
  pattern:   /   
  defaults:  { _controller: AcmeDemoBundle:Welcome:index, _locale: en }

acme_site:
  pattern:   /{_locale}
  defaults:  { _controller: AcmeDemoBundle:Welcome:index}
  requirements:
      _locale:  en|it

_demo_secured:
    resource: "@AcmeDemoBundle/Controller/SecuredController.php"
    type:     annotation

_demo:
    resource: "@AcmeDemoBundle/Controller/DemoController.php"
    type:     annotation
    prefix:   /demo
...

基本上,定义多个模式。您应该能够使用注释实现相同的目的:

/**
 * @Route("/", defaults={"_locale"="en"})
 * @Route("/{_locale}", requirements={"_locale" = "en|it"})
 */

希望有帮助!

于 2013-07-15T21:29:35.323 回答