wagtail-deprecated / wagtail-react-streamfield

Powerful field for inserting multiple blocks with nesting. (NO LONGER MAINTAINED - See Wagtail 2.13 Release Notes)
https://wagtail.github.io/react-streamfield/public/
BSD 3-Clause "New" or "Revised" License
74 stars 23 forks source link

Copying an entire StreamField (wagtail-modeltranslation) #51

Open jordanmt opened 4 years ago

jordanmt commented 4 years ago

We use wagtail-modeltranslation for internationalizing content on a per-field basis. StreamField content will often contain references that do not need to change between languages, so the workflow for translating a StreamField tends to be:

1) Create the content in the first language. 2) Copy the content from the base language's StreamField into a target language's StreamField (Wagtail Modeltranslation adds copy buttons alongside the StreamField label) 3) Edit text for the new language for CharBlocks and other text fields, while skipping things like references to images, links to internal pages, and so on.

Let's say we have a StreamField named content and two languages, English and French. Modeltranslation means that we end up with the fields content_en and content_fr. At first look, I think it will be possible to emulate the same behaviour that exists in Wagtail Modeltranslation for the old streamfields, adding copy buttons to the DOM that call streamField.init() like this:

window.streamField.init('content_targetlanguage', 'content_sourcelanguage')

Where _contentsourcelanguage is the serialized options data used to initialize the field.

I'm poking around to understand the codebase more to work on this, but I'd like to make sure I'm not underestimating the task or totally abusing streamField.init() by using it this way. Hence posting here as opposed to wagtail-modeltranslation.

Some initial questions and findings:

I also just wanted to say congrats on all the hard work, we've been following since the campaign :tada:

ayushin commented 3 years ago

would be great to have these two libraries working together out of the box