Is it possible to have different languages in Symfony2 (example.com/fr/page) but also default to example.com/page for English?

I'm trying to find a way to setup Symfony2 with language support but where it defaults to a default language if a language not entered.

So basically I want to allow these URLs for the 'page' page:

example.com/page
example.com/fr/page
example.com/de/page

etc...

I can easily do it if you always specify a language (e.g. example.com/en/page) but I don't want that. I want my links to be like this for English:

example.com
example.com/page
example.com/about

...and IF the user changes language to then append that to the URL:

example.com/fr
example.com/fr/page
example.com/fr/about

I currently use this but I have to specify a language on every request:

the_site:
    resource: "@MyBundle/Resources/config/routing.yml"
    prefix:   /{_locale}
    requirements:
     _locale: en|fr|es|de

I don't think this is possible??

Answers


You should use JMSI18nRoutingBundle. Scenario #2 (described in the docs) is what you want.


Need Your Help

Compare Values From 2 While Loops (PHP MYSQL)

php mysql sql

I'm trying to create all time standings for head to head matchups in a fantasy football league. I'm using two separate queries and grabbing the data with two separate while loops. I was hoping I co...

How to send associated data to server side in ext js4?

extjs proxy extjs4

I am new in extjs4 .I am using MVC structure.and I am going to save associated data to server side.I am getting stuck at this point.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.