Skip to content

Translate Web Stories using WPML #13446

Description

@diiegopereira

Feature Description

Hi there, this is Diego from the WPML Compatibility team.

We did some testing with the plugin and found that we can add translation support with WPML if the post_content value were wrapped in a gutenberg block.

For instance, instead of having just the HTML content inside post_content:

<html>
    ...
</html>

We could have something like:

<!-- wp:google/web-story -->
<html>
    ...
</html>
<!-- /wp:google/web-story -->

With this, we could use our language configuration file to find the strings using XPATH and then register and translate these strings: https://wpml.org/documentation/support/language-configuration-files/#gutenberg-blocks

Here is a quick example for the XML file:

<wpml-config>
  <custom-types>
    <custom-type translate="1">web-story</custom-type>
  </custom-types>  
  <gutenberg-blocks>
    <gutenberg-block type="google/web-story" translate="1">
      <xpath>/html/@lang</xpath>
      <xpath>/html/head/title</xpath>
      <xpath>//*[contains(@class,"text-wrapper")]//span</xpath>
    </gutenberg-block>
  </gutenberg-blocks>
</wpml-config>

This worked correctly as we can see here:

Would it be possible to implement this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Group: IntegrationIntegration with other platforms and pluginsGroup: WordPressChanges related to WordPress or Gutenberg integrationP3Nice to have

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions