Symfony2 - Translation of Sonata Datagrid filter statements fails for doctrine_orm_class field

In my Symfony project (2.5.7) I am using Sonata Admin Bundle 2.3. In the Admin class, I have set my DataGridForm like this:

protected function configureDatagridFilters(DatagridMapper $datagrid)    
{    
$datagrid    
->add('name')    
->add('created_by_user');    
}    

      

Where name

is text and created_by_user

is a one-to-many relationship to the user class. As a result, I have nice filters, but the statements in the field created_by_user

that are label_type_equals and label_type_not_equals are not translated. Translations are provided for another field:: name

label_type_contains, label_type_not_contains, label_type_equals which is good.

In my app /config/config.yml I have set:

framework:    
   translator: { fallback: "pl" }    

      

Translation is done using the SonataAdminBundle in SonataAdminBundle.pl.xliff, which is located in the vendor / sonata-project / admin-bundle / Resources / translations directory.

Any other label is translated. Only the ones related to the doctrine_orm_class type are not.

Please give me some idea to solve this problem. Thank.

+3


source to share


2 answers


There were missing translations as packages were updated. I have upgraded to SonataAdminBundle 2.3.3, but I am not so sure about this solution. However, I cannot repeat this problem.



0


source


The translation file for the SonataAdminBundle is for "internal global" messages.

You can add your translations to the default file, which must be located in Resources / translations / messages.pl.yml file to add translations.

But the recommended way is to create a separate file for one bundle or even one admin file: https://sonata-project.org/bundles/admin/2-3/doc/reference/getting_started.html#step-3-create-an- admin-service



Using TranslationDomain you can add a global file like. "YourBundle.pl.yml" or "MyAdmin.pl.yml":

# Acme/DemoBundle/Resources/config/admin.yml
services:
    sonata.admin.post:
        class: Acme\DemoBundle\Admin\PostAdmin
        tags:
            - { name: sonata.admin, manager_type: orm, group: "Content", label: "Post" }
        arguments:
            - ~
            - Acme\DemoBundle\Entity\Post
            - ~
        calls:
            - [ setTranslationDomain, [AcmeDemoBundle]]

      

0


source







All Articles