lazy-blocks
lazy-blocks copied to clipboard
WPML support
Issue description:
For translating websites we are using the WPML plugin, the problem is that the translation files contain a lot of LazyBlocks markup and are quite unreadable. Is it planned to add WPML support?
Lazy Blocks Version:
2.5.3
WordPress Version:
6.0.1
Hey.
The last time I checked it (long time ago :)), there was not an easy way to add WPML support, because there was a single way to add it - is to use the wpml-config.xml placed in the plugin folder.
We have WPML support in our plugins, where we created these configs manually:
- Ghost Kit - https://github.com/nk-crew/ghostkit/blob/master/src/wpml-config.xml
- Visual Portfolio - https://github.com/nk-crew/visual-portfolio/blob/master/src/wpml-config.xml
Since the Lazy Blocks is not a blocks set plugin and all blocks created with it are unique, we need to somehow provide information about block attributes to the WPML. And there was no such way before. If the WPML team added the possibility to provide such configs using PHP, we can easily add support.
Hi @nk-o,
There's no documented API on WPML, but some filter hooks could be used to programatically include custom configurations for blocks.
- filter hook
wpml_config_array: It's triggered when WPML fetches the XML configuration from different sources (themes, plugins, and remote configurations). It's the general filter applying on raw configuration data for all concerns (not only blocks). - filter hook
option_wpml-gutenberg-config: It's a filter on the specific block configuration (applied inget_option). This is the parsed configuration for blocks.
For reference, here's the specification for XML configuration.
Let me know if you need more info.
Thanks, Pierre from WPML
WPML support was added https://www.lazyblocks.com/docs/multilingual/ using the wpml_config_array filter as @strategio suggested.