WPML makes it easy to translate your site’s widgets, whether you’re using the Classic Editor and Legacy Widgets or Block Editor and Full Site Editing. You can translate your widgets using String Translation or by creating separate widgets for each language.
- Getting Started
- Registering Widgets as Translatable
- Translating Widgets Using String Translation
- Creating Widgets in Each Language
Start by installing and activating the WPML core plugin and WPML String Translation add-on.
WordPress 5.8 introduced block-based widgets. If you are using this version or later, please be sure you are using WPML 4.4.11 or later to ensure full compatibility.
In order to translate your widgets, you first have to tell WPML that they can be translated.
WordPress ships with a few default widgets. WPML automatically registers these for translation the moment you install WPML String Translation.
Themes and plugins often also provide custom widgets, or you may be coding your own widgets. If this is the case, you will notice that these widgets may not always show up automatically for translation on the String Translation page; or perhaps only the widget title registers but not other widget texts.
There are two ways to let WPML know that these exist and to register them for translation.
For this, please see our detailed documentation about registering widget fields using code.
One of the advanced features of String Translation is that it allows admins to select texts that are saved in the wp-options database table and register them for translation. Since WordPress widgets save their texts inside the wp-options table, this means that widgets also benefit from the feature.
Follow the steps outlined in our documentation to find and register the widget strings you would like to translate.
Once your widget strings have been added to the String Translation page, you can continue with translating them.
Visit WPML → String Translation and select Widgets in the domain selection dropdown. You will see all the default widgets registered available for translation. Or, you can use the search bar to find text from a custom widget.
Click the Plus icon to add translations in each language. Clicking outside the translation field automatically saves and publishes the translation.
You can use this method to manually create widgets in each language, or to display different widgets in different languages.
To use this feature, simply add or edit a widget on the Appearance → Widgets page in the WordPress admin area and choose which language to display it on using the dropdown.
Creating a Classic Widget
Creating a Block-Based Widget
Starting with WordPress 5.8, you can add widget blocks to your posts and pages.
Content in these blocks is translated along with the rest of the post or page. See our documentation on translating pages, posts, and custom post types for more details.