Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages in full color showing how to combine Symfony with Docker, APIs, queues & async tasks, Webpack, Single-Page Applications, etc.

Buy printed version

Multi-Language Support

1.3 version

Multi-Language Support


To focus our efforts onto a manageable number of packages, this package is currently not maintained. Security fixes and submitted bug fixes will still be released, but no new features should be expected. This bundle might have outdated documentation, there is no support from the CMF team and you should not expect bugs to be fixed.

If you want to help co-maintaining this package, tell us in a GitHub issue or in #symfony_cmf of the Symfony devs slack.

Setting the option add_locale_pattern to true in a Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page document will result in prefixing the associated route with /{_locale}. Using the native translation capabilities of PHPCR ODM it is now possible to create different versions of the document for each language that should be available on the website.

For example:

use Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page;

// ...

// pass add_locale_pattern as true to prefix the route pattern with /{_locale}
$page = new Page(array('add_locale_pattern' => true));

$page->setPosition($parent, 'hello-world');
$page->setTitle('Hello World!');
$page->setBody('Really interesting stuff...');
$page->setLabel('Hello World');

$dm->bindTranslation($page, 'en');

$page->setTitle('Hallo Welt!');
$page->setBody('Super interessante Sachen...');
$page->setLabel('Hallo Welt!');

$dm->bindTranslation($page, 'de');


Unless you write your own listener to update the locale before the routing takes place, your content will be loaded in the default locale and you will need to reload the content after the routing step to get the requested locale.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.