You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm the author of the Falang multilanguage plugin for wordpress (https://wordpress.org/plugins/falang/), trying to add a feature allowing site admins to translate their site from inside the gutenberg bloc editor
I have already make this with Elementor/Divi/Yootheme/WPbakery
The principle is to dynamically add some attributes you have to translate like input text/content/image depending of the block type
my Filter getSaveElement parse the attribute for each languages and i store the render
All work fine for simple blocks but for block like core/list-item it doesn't , probably due to the innerBlocks not set correctly (not set an empty array is used)
Here is a part of the function use for the getSaveElement Filter (call saveContentOrg function)
`
function saveContentOrg( element, blockType, attributes ) {
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I'm the author of the Falang multilanguage plugin for wordpress (https://wordpress.org/plugins/falang/), trying to add a feature allowing site admins to translate their site from inside the gutenberg bloc editor
I have already make this with Elementor/Divi/Yootheme/WPbakery
The principle is to dynamically add some attributes you have to translate like input text/content/image depending of the block type
For this i use the filter getSaveElement from #gutenberg/packages/blocks/src/api/serializer.js
The serializer.js funtion has this signature
export function getSaveElement(blockTypeOrName,attributes,innerBlocks = [])
in the serializer the filter i used but the innerBlocks are not in the parameters
return applyFilters('blocks.getSaveElement',element,blockType,attributes);
my Filter getSaveElement parse the attribute for each languages and i store the render
All work fine for simple blocks but for block like core/list-item it doesn't , probably due to the innerBlocks not set correctly (not set an empty array is used)
Here is a part of the function use for the getSaveElement Filter (call saveContentOrg function)
`
function saveContentOrg( element, blockType, attributes ) {
.......
Object.values(langues)
.forEach((langue) => {
let locAttributes = {...attributes}
attribs_to_change_content.forEach(attr => {
})
// return the element wrapped in a div
return element;
}`
my Question is, is there a way to get the innerBlocks of the getSaveElement from the serailized.js in the 'blocks.getSaveElement',
Thanks a lot.
if this is not the right place, just let me know.
Stéphane
Beta Was this translation helpful? Give feedback.
All reactions