Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default locale doesn't change in symfony 4

I'm trying to change locale from 'en' to 'lt' as a default, but not changing at all it only adds as a "Fallback locale", but not as a main. So following that problem I'm getting another one, that routes by language is incorrect. So the first problem should solve all others.

services.yaml

parameters:
    locale: 'lt'

framework.yaml

framework:
    default_locale: '%locale%'

and results:

enter image description here

enter image description here

So by that my Routes using EN language routes instead LT

Any solutions? tried without %locale% variables, clearing cache etc..

like image 636
GiedriuX Avatar asked Jun 16 '18 11:06

GiedriuX


1 Answers

If you are using translations, have a look in translations.yaml :

framework:
    default_locale: '%locale%'
    translator:
        default_path: '%kernel.project_dir%/translations'
        fallbacks:
            - '%locale%'

The %locale% variable is defined in services.yaml.

If you're using an event subscriber to track a user defined locale you might want to check that event subscriber's config in services.yaml :

 App\EventSubscriber\LocaleSubscriber:
    arguments: ['%kernel.default_locale%']
like image 127
Rmy5 Avatar answered Oct 26 '22 00:10

Rmy5