WPBakery Page Builder Compatibility with WPML

How the integration of the WPBakery Page builder works with WPML

To understand how the WPBakery Page builder works with WPML, let us start by creating a simple page using the WPBakery Page builder. We will include a few modules, such as a Text Block, a Message Box, and a Hover Box.

A simple page created using WPBakery page builder

As you already know, these modules generate shortcodes, which wrap the content. You can see an example of this in the following screenshot:

The shortcodes wrapping the content

Our objective is to configure WPML to find the content (textual elements), such that it can display it to the user on the Translation Editor screen. To enable the Translation Editor, go to the WPML -> Translation Management page, and click on the Multilingual Content Setup tab. In the How to translate posts and pages section, select Use the translation editor option, and click Save.

Enable the Translation Editor

To translate the page we created, click on the “plus” icon found in the language meta-box on the top right.

Click on the plus icon to translate the page

This will take you to the Translation Editor screen, where you can translate your page. Fill in your translated text, and choose Translation is complete for each field, then click on the Save & Close button.

Translate the page and then click on Save & Close

When we view the translated page in the Text editing mode, we can now see the translated strings wrapped with the page builder shortcodes.

Translated page showing the translated strings wrapped by the page builder shortcodes

Updating the language configuration file

You might need to update the page builder short-code in the language configuration file for different reasons:

  1. adding a new short-code to the page builder;
  2. adding a new attribute to an existing short-code; and
  3. removing an obsolete short-code.

You can download the language configuration file from our repository. Add the shortcodes or attributes to the existing shortcodes to the language configuration file

For the authors who are bundling a customized version of WPBakery Page Builder in their theme, please take into consideration that you will need to update the language configuration file of the customized version of the plugin.

Page builder shortcode structure in the language configuration file

To extract strings from pages built using the WPBakery Page builder and load them on the Translation Editor screen, we need to configure WPML to identify the shortcodes and attributes containing the strings that require translation. This is done by adding a file, called wpml-config.xml, which is typically placed in the root folder of your theme. For WPBakery Page Builder, we are hosting the language configuration file on our servers. It is set to override the local configuration file placed in WPBakery’s Page Builder root folder, ensuring that the configuration file is always up to date.

The wpml-config.xml file is also used to configure the following elements:

  1. Custom fields
  2. Custom taxonomies
  3. Admin texts / wp_options
  4. Language switcher configuration
  5. Page builder shortcodes

See our detailed documentation to learn more about the language configuration file structure and syntax.

As an example, let us see how we added the Tabs shortcode to the wpml-config.xml file.

            <attribute encoding="allow_html_tags">title</attribute>

The structure of the above example can be broken down as follows:

  • All the shortcodes are wrapped with the shortcodes
  • The shortcode tag wraps all the tags belonging to one, single shortcode.
  • The tag tag defines the name of the shortcode, which in this case, is the vc_tta_tabs.
  • Shortcodes can have one or more attributes; hence, we wrap them in the attributes (plural) tag and use the attribute (singular) tag to define the title of each attribute. In this case, we have the title attribute

For shortcodes that include link attributes, you can make internal links automatically point to the translated version of that post by using the type option for the attribute. Here is an example:

            <attribute encoding="allow_html_tags">title</attribute>
            <attribute encoding="vc_link" type="link">href</attribute>

Testing the language configuration file

To test the updated language configuration file, follow these steps:

    1. Set up an installation having both WPBakery Page Builder and WPML activated. Activate the String Translation, Translation Management, and Media Translation add-ons.
    2. You will need to override the remote language configuration file with the updated one. To do this, navigate to WPML -> Translation Management page, and click the Custom XML Configuration tab. Copy the content of your updated language configuration file to the editor, and click Save.
Overriding the remote language configuration file with the updated one
    1. Create a new page, and add the new module(s) to it. In case you updated some attributes for existing modules, add these to the page as well. In this example, we will assume that the Call To Action module was newly added to the WPBakery Page builder. Add it to the page, and Publish.
Add the new module to the page and Publish
    1. Click on the plus icon to translate the page. This will take you to the Translation Editorscreen.
    2. Ensure that the module textual elements are displayed on the Translation Editor screen.
    3. Fill in your translated text. Select Translation is complete for each field, then click on the Save & Close button.
Translate the textual elements and click Save and Close
    1. Check the translated page on the front-end.
Translation working on the front-end

The translated page shows all the translated strings, implying that the updated language configuration file is working properly. In case you are encountering any issues, please contact our compatibility development team. They will be happy to check issues related to the language configuration file.

Once done with the tests, please submit a merge request to our repository. Our compatibility developers will receive your requests and review it.

Please note that the language configuration file hosted on our repository is for the default version of WPBakery Page Builder. In case you are updating the language configuration file of a customized version of WPBakery Page Builder, apply the changes to the configuration file inside your plugin’s root folder.