repincln
repincln

Reputation: 2049

translations in sonataAdmin

I have entity with title, description and image. Title and description are translatable and want to have this in three languages: en, de and sl. Default locale is sl.

Now I configure a2lix, SonataAdmin and StofDoctrineExtension.

What is the best practice (and of course correct) for using translatable in sonata Admin.

version 1:

$formMapper
        ->add("title") //default language
        ->add('description') //default language
        ->add('image', 'sonata_type_model_list', array(), array('link_parameters' => array('context' => 'default')))
        ->add('translations', 'a2lix_translations_gedmo', array(   // Use the old gedmo strategy
            'translatable_class' => 'My\CoreBundle\Entity\SliderTranslation',
    ));

title and description are separated for default language. Other locales (en, de) are in translatable tabs.

version 2:

$formMapper
        ->add('image', 'sonata_type_model_list', array(), array('link_parameters' => array('context' => 'default')))
        ->add('translations', 'a2lix_translations_gedmo', array(   // Use the old gedmo strategy
            'translatable_class' => 'My\CoreBundle\Entity\SliderTranslation',
    ));

title and description are not separated and are included in translation tabs. Translation tabs are sl, en and de.

Upvotes: 0

Views: 337

Answers (1)

webda2l
webda2l

Reputation: 6708

The second one become the standard in the 2.x version of A2lixTranslationForm.

I advice to try this version 2.x with another strategy: A2lix, Knp or Prezent. Theses strategies are all compatibles each other in the way that they store their data in the database, contrary to the Gedmo, and so, you'll can switch easily from one to another in the future.

You can have a look on https://github.com/sonata-project/SonataTranslationBundle too, currently in developement.

Upvotes: 1

Related Questions