How to properly translate strings in SonataAdminBundle

117 views
Skip to first unread message

reyn...@gmail.com

unread,
Dec 11, 2015, 10:58:01 PM12/11/15
to sonata...@googlegroups.com
I am trying to translate some Sonata Admin - list page - strings using `.xliff` file inside my bundle. Those strings belongs to my bundle and not to Sonata so this are the steps I have follow:

 - Create a `.xliff` file under: `src/Clanmovil/PlatformBundle/Resources/translations/PlatformBundle.es.xliff` as follow:

        <?xml version="1.0"?>
        <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
            <file source-language="en" datatype="plaintext" original="PlatformBundle.en.xliff" >
                <body>
                    <trans-unit id="name">
                        <source>name</source>
                        <target>Nombre</target>
                    </trans-unit>
                    <trans-unit id="description">
                        <source>description</source>
                        <target>Descripción</target>
                    </trans-unit>
                    <trans-unit id="active">
                        <source>active</source>
                        <target>Activo?</target>
                    </trans-unit>
                </body>
            </file>
        </xliff>

 - Setup `label` property under `src/Clanmovil/PlatformBundle/Controller/Admin/CategoryAdmin.php` as follow:

        class CategoryAdmin extends Admin
        {
            ...

            // Fields to be shown on lists
            protected function configureListFields(ListMapper $listMapper)
            {
                $listMapper
                    ->add('name', null, array(
                        'label' => 'name'
                    ))
                    ->add('active', null, array(
                        'label' => 'active'
                    ));
                ...
            }

            ...
        }
 
 - Setup `app/config/config.yml` as follow:

        parameters:
            locale: es

        framework:
            #esi:             ~
            translator:      { fallbacks: ["%locale%"] }
            default_locale:  "%locale%"
            ....
            
And is not working I am still seeing `name` and `active` strings on list page and I don't know what I am missing. I have read several posts as [this][1], [this][2] and many more. Can any give me some advice?

Reply all
Reply to author
Forward
0 new messages