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?

1 Answers1

0

I'm not sure what your controllers folder looks like, but I was able to solve your problem with the AcmeDemoBundle WelcomeController like this:

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
...

Basically, define multiple patterns. You should be able to achieve the same sort of thing with annotations:

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

Hope that helps!

mattexx
  • 6,456
  • 3
  • 36
  • 47