sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

SonataAdminBundle use incorrect translation locale #292

Closed zhil closed 13 years ago

zhil commented 13 years ago

For some reasons I cant force SonataAdminBundle to use my local

  1. I have created bundle and placed file Resources/translations/SonataAdminBundle.ru.yml
  2. I have set in config.yml [code]translator: { fallback: ru }[/code]

My locale loaded correctly - because messages which are missed in SonataAdminBundle locale (breadcrumbs, my custom messages) are translated correctly.

But for all messages, which exists in Sonata locale files - 'en' translation used and I cant override it in my locale. I supposed, maybe they have something like [code]$this->get('session')->setLocale('en_US');[/code] and some kind of language selection in some settings page, but no function setLocale calls was founded in bundle.

Right now I dont have any ideas what can I do next, any suggestions are welcome :)

Topic is reposted here http://forum.symfony-project.org/viewtopic.php?f=23&t=37100

stof commented 13 years ago

@zhil the default locale in Symfony is en unless specified differently in your config. So if you don't set the locale explicitly (either through the _locale routing param or through $session->setLocale()), the locale will be en.

zhil commented 13 years ago

thanks a lot for the quick response :)

well, I have set in my app/config/config.yml translator: { fallback: ru }

should I add something more to it? :)

stof commented 13 years ago

This is about the translation fallback, not about the session default locale.

framework:
    session:
        default_locale: ru
zhil commented 13 years ago

thanks a lot, works :)

riki137 commented 5 years ago

If anybody here wants to force locale, you can just do:

admin_area:
    resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml"
    prefix: /admin
    defaults:
        _locale: en

in project/config/routes/sonata_admin.yaml