我遇到的问题是,当用户在登录页面中更改语言时 - 它可以工作,但在用户登录后 - 它又恢复为默认状态.如何在登录前保持同一语言用户的选择,登录后留下来?我已经尝试在stackoverflow上查找,但无法找到任何工作结果.
security.yml:
security: encoders: AppBundle\Entity\User: algorithm: bcrypt role_hierarchy: ROLE_ADMIN: ROLE_PREMIUM ROLE_PREMIUM: ROLE_USER providers: our_db_provider: entity: class: AppBundle:User property: email in_memory: memory: ~ firewalls: # disables authentication for assets and the profiler, adapt it according to your needs dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false main: anonymous: ~ form_login: #galima nurodyti kur nukreipia loginas login_path: login check_path: login csrf_token_generator: security.csrf.token_manager logout: path: /logout pattern: ^/ http_basic: ~ provider: our_db_provider access_denied_url: homepage
使用routing.yml
app: resource: "@AppBundle/Controller/" type: annotation prefix: /{_locale} requirements: _locale: lt|en|ru root: path: / defaults: _controller: FrameworkBundle:Redirect:urlRedirect path: /%locale%/ permanent: true login: path: /{_locale}/login defaults: { _controller: AppBundle:Security:login } requirements: _method: GET _locale: lt|en|ru logout: path: /logout defaults: _controller: FrameworkBundle:Redirect:urlRedirect path: /{_locale}/login permanent: true register: path: /{_locale}/register defaults: { _controller: AppBundle:Registration:register } requirements: _method: GET _locale: lt|en|ru
语言改变了:
任何想法或例子将不胜感激!