lazy-blocks icon indicating copy to clipboard operation
lazy-blocks copied to clipboard

WPML support

Open websoluteAT opened this issue 3 years ago • 1 comments
trafficstars

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

websoluteAT avatar Aug 04 '22 07:08 websoluteAT

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.

nk-o avatar Aug 08 '22 12:08 nk-o

Hi @nk-o,

There's no documented API on WPML, but some filter hooks could be used to programatically include custom configurations for blocks.

  1. 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).
  2. filter hook option_wpml-gutenberg-config: It's a filter on the specific block configuration (applied in get_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

strategio avatar Nov 18 '22 10:11 strategio

WPML support was added https://www.lazyblocks.com/docs/multilingual/ using the wpml_config_array filter as @strategio suggested.

nk-o avatar Dec 04 '22 09:12 nk-o