TranslationFormBundle icon indicating copy to clipboard operation
TranslationFormBundle copied to clipboard

[Feature] Allow additional translations dynamically

Open Phenix789 opened this issue 7 years ago • 3 comments

Subject

In one of my current project, I had to allow additional translations directly from user interface. This feature doesn't exist in this bundle, so I create a TranslationsTypeExtension (and few other code) to add this behavior.

I would like to know if you could be interested to add this behavior inside this bundle ?

The work is done via a new EventSubscriber, a little modification in widget and a short js class.

Example

$form->add('translations', TranslationsType::class, [
  'allow_additional_translations' => true,
  'fields' => [
    //...
  ],
]);

Screenshot

capture du 2018-10-22 15-03-13

Phenix789 avatar Oct 22 '18 13:10 Phenix789

@webda2l WDYT?

Phenix789 avatar Oct 23 '18 15:10 Phenix789

@Phenix789 I would be interrested in getting your solution, would you mind share it? I have the exact same need: let people to add their own translation at runtime.

I've tried to basically duplicate english field and tab, but their submission to the form is not taken into account.

Thibibi avatar May 18 '22 21:05 Thibibi

@Thibibi Thanks for your interrest, but I'm not anymore on this projet from few years. But, the code wasn't so difficult if you understand the Form extension.
Have a look to Form CollectionType too.

Basically, if I remember, I had a TranslationsTypeExtension to add property allow_additional_translations.
An event listener to handle the dynamic translations.
And finally, a short js class to manage the + button and the html template.

Sorry, I can't help you more ...
And, I think with latest Symfony version, some part should be easier.

Phenix789 avatar May 19 '22 06:05 Phenix789