I seem to have a missunderstanding in some aspects of the locale and subdomain pattern in Symfony2 routing.
Why doesn't this work?
routing_de:
host: "dev.de.example.com"
resource: "@AcmeDemoBundle/Resources/config/routing_de.yml"
prefix: /
routing_en:
host: "dev.en.example.com"
resource: "@AcmeDemoBundle/Resources/config/routing_en.yml"
prefix: /
Additionally I want to set the locale based on the subdomain. I would assume that like this would set the default locale:
routing_de:
host: "dev.{_locale}.example.com"
resource: "@AcmeDemoBundle/Resources/config/routing_{_locale}.yml"
requirements:
_locale: de|en
prefix: /
Even if I use the subdomain listener described here (and adjust it to Symfony2.2) I can only set the _locale in the Controller. Somehow Twig gets a different locale than the Controller
<a href="{{ path('register', {'_locale': app.request.attributes.get('_locale')}) }} ">Register</a>
will return en, whilst
$this->getRequest()->getLocale();
will return my default locale set in the subdomain listener.
EDIT 2013/04/02 I tried to reimplement this solution (http://www.ricardclau.com/2011/09/littleweb-a-small-project-in-symfony2-chapter-1-translations/) and adjusted it for subdomains, but this seems not to work either.