WPML can read a configuration file that tells it what needs translation in themes and plugins. The file is named wpml-config.xml and it’s placed in the root folder of the plugin or theme.
On This Page:
- The purpose of the language configuration file
- Generating the wpml-config.xml file automatically
- Structure and Syntax
- Using WPML language configuration file with child themes
As part of achieving compatibility with WPML, you should also create a configuration file that will help you with maintaining compatibility in your future releases. WPML can translate anything on your WordPress site, but you need to tell it what needs translation. This file does that.
Go to the WPML → Settings page.
This page tells WPML everything it needs to know, including which custom fields to translate or synchronize, which custom post and taxonomies should be multilingual and even which admin texts to translate.
The language configuration file includes this information so that each and every user doesn’t need to manually enter it in the admin page.
For some of the themes and plugins, we are hosting the language configuration files on our servers. You can see a list here. It is set to override the local language configuration file that is placed inside the root folder of the theme or plugin.
WPML also allows you to manually override any settings loaded by theme and plugin language configuration files. This applies to both, language configuration files inside the root folder of the theme or plugin and the language configuration files hosted on our servers.
If you are not familiar with creating XML files, our team has created the Multilingual Tools plugin that makes this task easier. Although it was initially conceived as a tool for helping theme and plugin authors to make their products multilingual-ready, it can easily be used to generate your own wpml-config.xml file.
To learn more about generating your wpml-config.xml file, visit the Multilingual Tools plugin’s page. Specifically, look under the How do I generate language configuration files using Multilingual Tools? section.
Once you have the configuration file, add it to the root of your theme’s folder. If you already have one, do not overwrite it. Instead, edit your original XML file and add the code generated with the Multilingual Tools plugin.
Please note that this plugin is not intended to be used on the live, production sites.
To read this tutorial and build language configuration files for your themes and plugins, you can start with this example one – wpml-config.zip.
You’ll need to edit it, but you can use the sections and structure of this file.
WPML lets you configure a number of elements using the wpml-config.xml file. Use the following guides to find additional information and instructions on how to make specific site elements translatable:
- Translate Custom Shortcodes with WPML
- Register Page Builder Content for Translation
- Set Translation Options for Custom Fields Using WPML Configuration File
- Register Custom Terms, Types and Taxonomies as Translatable
- Make Custom Gutenberg Blocks Translatable
- Translate Texts that Theme and Plugins Save in wp_options
- Customize WPML Language Switcher Using WPML Configuration File
If you are using a child theme, the language configuration file of the parent theme overrides the one found in the child theme. WPML provides a configuration page that allows you to easily override this with any custom settings.
Let us consider an example where the language configuration file of the parent theme is setting the custom post type “Property” to be translatable.
If you are using a child theme and want to set the custom post type “Property” to be non-translatable, navigate to the WPML → Settings page and click on the Custom XML Configuration tab. Use the editor to set the custom post type “Property” to be non-translatable. Simply, set the translate attribute value to 0 instead of 1.