Labels in Sonata Admin Bundle Labels in Sonata Admin Bundle php php

Labels in Sonata Admin Bundle


for translate menu and forms override file: SonataAdminBundle.[your_language].xliff(with content from: vendor/sonata-project/admin-bundle/Sonata/AdminBundle/Resources/translations/SonataAdminBundle.[your_language].xliff), put file in:

app/Resource/SonataAdminBundle/translations/

full path:

app/Resource/SonataAdminBundle/translations/SonataAdminBundle.[your_language].xliff

If you want to translate your labels for field, you must create translate file in your bundle, for example:

src/YourAlias/YourNameOfBundle/Resources/translations/YourAliasYourNameOfBundle.[your_language].xliff

if your Admin class is in

src/YourAlias/YourNameOfBundle/Admin/YourClassAdmin.php

Sonata use FOSUserBundle and if you want change translation for users module, you must ovverride file: FOSUserBundle.[your_language].yml in:

app/Resource/FOSUSerBundle/translations/FOSUserBundle.[your_language].yml

and analogously for SonataUserBundle

I use that configuration and everything works!


Expanding on @mkjasinski's comment above, the Symfony Translation component expects to find a _locale property on the request. If this is missing, or no translation can be found for the specified locale, it uses a fallback value. However this fallback value is also blank by default hence seeing the translation labels instead of text.

To fix this, set the default translation locale by adding the following to config.yml:

framework:  #...  translator:    fallback: %locale%