Skip Navigation
Updated
October 5, 2023

Multilingual Tools Plugin

The Multilingual Tools plugin can help theme and plugin developers to test their products’ multilingual capabilities. It will automatically add language code or custom notices to translated content, allowing the developer to review what is working correctly and what requires modification to be translated.

With this tool you can:

  • Automatically generate strings for translations
  • Add language information to duplicated posts
  • Generate a WPML configuration file (wpml-config.xml)
  • Register custom Elementor widgets for translation

The end result of using the Multilingual Tools plugin is shown below:

English French
English French

How do I install and use Multilingual Tools to automatically generate translations?

This tool is free and available for download from the following GitHub page:

Note that WPML Multilingual CMS, WPML String Translation, and WPML Translation Management plugins are required for Multilingual Tools to work.

The Multilingual Tools plugin will automatically generate translations (appending language code with original strings) for:

  • Posts, pages, and custom types
  • Custom fields
  • Tags, categories, and custom taxonomies
  • All translatable strings

Automatic translation generation is achieved by following these three steps:

Basic WPML setup

In this tutorial, we will activate the “Twenty Sixteen” theme, and install and activate WPML Multilingual CMS, WPML String Translation, WPML Translation Management, and Multilingual Tools plugins.

WPML’s Getting Started Guide will help you to set up WPML in only a few minutes. Make sure to add at least one secondary language and set the language switcher (which is an easy way to switch between languages) to be displayed in the footer area in the front end.

The Multilingual Toolset Overview page

You can navigate the overview page by navigating to Multilingual ToolsOverview. On this page, you can see the remote WPML language configuration files that are loaded along with the translation preferences for custom posts, fields, and taxonomies.

Multilingual Tools Overview page

Scanning your theme/plugin code for text

Every WordPress theme and plugin has some hard-coded text. If you’ve followed the WordPress coding guidelines, all these texts will be wrapped in gettext calls, described in the WordPress i18n guide. If not, now would be a great time to fix this.

  1. Navigate to WPML → Theme and plugins localization.
  2. Select the Translate the theme and plugins using WPML’s String Translation option in the Localization options section.
  3. Scroll to the Strings in the themes section. Select themes you want to scan and click the Scan selected themes for strings button.
  4. If you are testing a plugin, scroll to the Strings in the plugins section. Select plugins you want to scan and click the Scan selected plugins for strings button.
Scanning themes and plugins for strings
Scanning themes and plugins for strings

Now, WPML is capable of translating all strings that are wrapped in Gettext calls and also has translations for the WordPress core text.

Auto-duplicate content for other languages

Now that we have all strings scanned, we can generate translations for the site. Remember that the Multilingual Tools plugin will only translate the sample content that you’ve created. If your theme or plugin requires test content, you should populate it first.

  1. Navigate to Multilingual Tools → Settings
  2. From the Add language information to post duplicate section choose which elements in the posts to auto-translate.
  3. Choose the template of the automatic translated text from the drop-down menu, for example, ([%language_name%] %original_string%). This will append the language name, code, or custom formatted string to your translation.”
  4. Click on the Save button.

Add language information to post duplicate

  1. Navigate to WPML → Translation Management
  2. On the Translation Dashboard tab, scroll down and choose the pages and posts that you want to set as translatable.
  3. From the Translation options section, choose the Duplicate content option and click on the Duplicate button.

Duplicate content

  1. Navigate back to Multilingual Tools → Settings.
  2. Choose the strings within a specific context to translate from the drop-down menu.
  3. Choose the translation languages.
  4. Choose the template of translation from the drop-down menu.
  5. Click on Generate strings translations.

auto generate strings translations

Now, you can review your site’s front-end and see the results. In our example, we’ve selected the default Twenty Sixteen theme. You can see that all of the site’s content appears perfectly translated when we view the French content.

French

Hopefully, your theme/plugin translations will be complete too. If they aren’t, have a look at the WordPress i18n guide to learn how to achieve this.

Remember, the purpose of the Multilingual Tools plugin is to quickly show you what needs attention by illustrating what is translatable (and what is not) on the front-end and help you to re-test after you’ve made changes to your code. The tool cannot automatically edit code and fix compatibility problems.

How do I generate language configuration files using Multilingual Tools?

WPML can read a configuration file that points out strings that need translation and saves preferred translation options for themes and plugins. The file is named wpml-config.xml and it’s placed in the root folder of the plugin or theme. Read more about how the language configuration files work.

To generate your theme/plugin language configuration file, follow these steps:

Go to the Multilingual Tools → Configuration Generation screen. You will find five sections:

  • Custom Post Types (CPTs)
  • Custom Taxonomies (CTs)
  • Custom fields
  • Admin Texts
  • Shortcodes

Each section will allow you to set whether it is to be translatable. Note that for this example, we activated the Larx theme because it includes CPT, CT, custom fields, admin texts, and shortcodes.

  1. In the CPT section, choose the custom posts that you want to set for translation and choose the translate option. In our case, these are “testimonials” and “portfolio”.
  2. In the CTs section, choose the CTs that you want to set for translation and choose the translate option. In our case, it is “project-type”.

set CPTs and CTs for translation

  1. Custom fields are set for translation in a different manner, as custom fields can be found in regular posts, pages, or custom posts of the theme. You will need to create a test post, add values to the custom fields, and publish it.

As an example, we will create a regular post and set its custom fields; in our case, they are “Sidebar Position” and “Theme style”. Then, click on the Publish button.

  1. Navigate to Multilingual Tools → Configuration Generator to find the custom fields, (_cmb_post_sidebar_layout) and (_cmb_theme_style), registered. Choose them and set them to copy, as they are layout settings and don’t require actual translation. If the custom filed is a user input and requires translation, set it to translate.

set custom fields for translation

set custom fields for translation-2

Note that for custom fields that require translation (a CT that requires the user to type in a string), you will choose the translate option.

  1. To set admin texts for translation, we will need to take the option name from the database. Follow these steps:
  • Go to the page where admin texts are saved. In our case, we will navigate to the Larx → Footer settings tab.
  • Copy the footer text.
  • Open phpMyAdmin or Adminer. Then, choose the wp_options table and search for the text, as shown below.

search DB for theme option name

  • Now, we have the theme option name from the database.

search DB for theme option name-2

  • Navigate back to Multilingual Tools and choose the theme options name from the drop-down menu.
  • You will need to decide which options need to be translated. For the theme in this example, we set the logo and footer text to be translated.

set admin text to be translatable

  • Scroll down and choose Save to theme directory to automatically place the language configuration file in the theme folder or choose Save to file to download the file. Then, click on the Generate button.
  1. In order to translate the text wrapped in a shortcode, you need to add the shortcode tag and attributes under the Shortcode section on the Configuration Generator page. This allows WPML to display the text that the user wants to translate on the translation editor page only and not the entire shortcode along with the text. Check our language configuration file guide to know more about defining shortcodes in WPML’s language configuration file.

     

    To add a shortcode, simply click the Add shortcode button then type in the shortcode tag and attribute(s).

    Adding shortcode tags and attributes

How do I register custom Elementor widgets for translation using Multilingual Tools?

The Multilingual Tools plugin includes a WPML – Config Generator for Elementor. Once you add custom Elementor widgets you want to register for translation to a page, the tool creates the initial XML code for them.

 

Learn more on the page about registering custom Elementor widgets for translation using the Multilingual Tools plugin.

Conclusion

The Multilingual Tools plugin can help you to automatically generate translations by appending language code to your theme/plugin original strings; thus, you can test the multilingual abilities of your theme/plugin. It can also help you to generate a WPML language configuration file in a few minutes.