I'm using symfony2.8. I made translation yaml files for couple lang (en|de|cz). Then I added requirements to routing:
(global) app\config\routing.yml
comflex_w2:
resource: "@ComflexW2Bundle/Resources/config/routing.yml"
defaults: { _controller: ComflexW2Bundle:Home:index, _locale: en }
prefix: /{_locale}
requirements:
_locale: en|de|cz
and inside bundle src\Comflex\W2Bundle\Resources\config\routing.yml
comflex_w2_home:
pattern: /
defaults: { _controller: ComflexW2Bundle:Home:index}
comflex_w2_login_check:
path: /login_check
defaults: { _controller: ComflexW2Bundle:User:authorization }
Now, when I go to host/web/app_dev.php/de or .../en, or .../cz then transations are worked, but when request doesn't contain locale like host/web/app_dev.php, then I get
"No route found for "GET /" with 404 error
How to set locale in url automatically from session files (only after user logged) or from browser local or finally set as en when nobody is logged.
I found entry default_locale: "%locale%" in app\config\config.yml but i have no idea how it's work and where "%locale% set is.
_locale: en|de|cz. This parameter than defines locale in your application. Look at this question stackoverflow.com/q/34109527/5298034, same problem. - Max P.