ladela / personal-translations-widget-bundle
Adds translations widget based on Personal translations
Installs: 17 690
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 2
Open Issues: 0
Type:symfony-bundle
Requires
- stof/doctrine-extensions-bundle: *
- symfony/symfony: >=3.2.0
- twig/extensions: @stable
README
Add to composer.json:
"ladela/personal-translations-widget-bundle" : "dev-master"
Add to AppKernel.php:
new Ladela\PersonalTranslationsWidgetBundle\PersonalTranslationsWidgetBundle(),
To edit template, copy this file:
Resources/views/Form/translatable_field_widget.html.twig located in the bundle directory
~~~~
to
~~~~
app/Resources/PersonalTranslationsWidgetBundle/views/Form/translatable_field_widget.html.twig located in the project root
Languages configuration
Getter service
The service should have a tag languages_getter and return array of languages: code = > name
tags:
- { name: languages_getter }
use Ladela\PersonalTranslationsWidgetBundle\TranslationsGetter\TranslationsGetterInterface;
class LanguagesGetter implements TranslationsGetterInterface
{
public function getLanguages()
{
return array('en' => 'English', 'de' => 'Deutsch');
}
}
or use languages as array:
personal_translations_widget:
languages:
en: English
es: Spanish
Sonata Admin sample
protected function configureFormFields(FormMapper $form)
{
$subject = $form->getAdmin()->getSubject();
$form
->add('translations', 'translatable_field', array(
'personal_translation' => 'Site\BaseBundle\Entity\AccommodationTranslation',
'fields' => array('title', 'description', 'secondary_text'),
'widgets' => array('title' => 'text', 'description' => 'textarea', 'secondary_text' => 'textarea'),
'field_options' => array('secondary_text' => array('attr' => array('class' => 'text-field')))
))
}