3

I have installed fos user bundle, i18n routing bundle and translation bundle, and enabled them in the app kernel.

For my config I have:

parameters.yml

parameters:
    locale: en

config.yml

framework:
    translator:
        enabled: true
    default_locale:  %locale%

jms_i18n_routing: 
    default_locale: %locale%
    locales: [%locale%, fr, es]
    strategy: prefix_except_default

And security config with all paths beginning with ^/[a-z][a-z]/

security.yml

access_control: 
    - { path: ^/[a-z][a-z]/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/[a-z][a-z]/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/[a-z][a-z]/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }

    - { path: ^/[a-z][a-z]/profile/, role: ROLE_USER }

I have also set routes not paths in fos_user config...

Everything is OK with the routes and URLs in the browser.
But the only problem is that views are not translated. They always come with english, the default locale when I have /fr/my-path

locale route attribute is fr.
_locale is fr.
request::locale is fr.
hl cookie is fr.

I have set a break point in Symfony\Component\Translation::trans() and it seems that the getLocale() always return en.

Did I have misconfigured something? Or is it may be a bug?

4

0 回答 0