The Best Multilanguage Plugin supporting the FSE [closed]

Proposed solution – a new plugin

A new plugin built around the blocks and possibilities of the block editor. Having translations done within the FSE / Block Editor. The description below will focus on the translations of the Block items, because solving non-block based items is probably really easy since all multilanguage plugins already do it.

Technical overview

  • Block attributes will contain references to translations
  • Translations will contain the full block content and it will be the choice of the editor if they want to translate blocks with children or only the lowest level.
  • When rendering blocks the correct translated item will be fetched from the translation table.
  • In order to speed things up we should hook into a general page hook just before individual block rendering, fetch all block translate ids, get all translations in a single query (for the currently selected language), store them in a memory variable and use that variable when rendering the blocks – that will cause only a single extra SQL lookup per page/post
  • This will also mean if the plugin is deactivated all content will continue to work without any cleaning necessary

Sample block

Block content

<!-- wp:paragraph {"translation":{"id": "idofdatabaseitem", "temp" : { "currentlanguage": "de", "pageid": 123}}} -->
<p class="_text_highlighted">This is the currently displayed language</p>
<!-- /wp:paragraph -->

Issues that needs to be addressed

  • We must hook the onload/onpublish/onsave of the FSE to make sure as possible that the stored content of a post is the base language (for page rendering it should not matter as we will just get the content from the database) however we want to make sure that the editor has a consistent content.
  • We must hook the FSE in order to load the correct block content for the selected editing language. It is possible to hook into existing block editors like this (https://mariecomet.fr/en/2021/12/14/adding-options-controls-existing-gutenberg-block/)
  • We must hook copy/paste for copy paste operations in the same page as we want to duplicate translations and not link them to the old ones
  • We must hook copy/paste or page duplicate or maybe better make sure to keep track of which page ID a translated block belongs to (so in the translations table keep ID, page_ID, content) so we can detect when a block is a copy from another page and we can duplicate the translations.

Next Step

  • Do you think this is possible?
  • Should we do this together?
  • Other questions or comments?