Skip Navigation
Updated
January 5, 2024

Themes and plugins sometimes include texts as part of the options they save in the wp_options table. WPML lets you translate such texts by replacing get_option calls with the translations you specify in the wpml-config.xml file. 

The wpml-config.xml file is a configuration document that instructs WPML which strings in the saved options need translation.

This guide is for developers who create their own themes and plugins. If you’re trying to translate strings coming from third-party themes and plugins, read our page about finding strings that don’t appear on the String Translation page.

Need to generate a wpml-config.xml file? Visit our step-by-step guide for automatically generating a configuration file using the Multilingual Tools plugin.

Translating Strings in the wp_options Table

When themes and plugins use get_option, they read values from the wp_options table. WPML can filter these calls and provide translation to the values of these options.

This works if the wp_option record is a simple string but also when it’s a serialized array.

To translate a single option, add a key entry under admin-texts. To translate a serialized array, add several keys under a key, like you can see in my_plugin_options in the example below.

Admin texts in the language configuration file
<wpml-config>
  <admin-texts>
    <key name="my_plugins_options">
      <key name="option_name_1" />
      <key name="option_name_2" />
    <key name="options_group_1">
      <key name="sub_option_name_11" />
      <key name="sub_option_name_12" />
    </key>
      <key name="options_group_2">
      <key name="sub_option_name_21" />
    <key name="sub_option_name_22" />
    </key>
    </key>
  <key name="simple_string_option"/>
</admin-texts>
 
</wpml-config>

It’s possible to use the wildcard * in sub-keys like the following case.

Example of using wildcard
<wpml-config>
  <admin-texts>
    <key name="testing_option">
      <key name="*"/>
    </key>
  </admin-texts>
</wpml-config>

It’s equal to this code:

The equivalent code
<wpml-config>
  <admin-texts>
    <key name="testing_option">
      <key name="sub_key_1"/>
      <key name="sub_key_2">
        <key name="sub_sub_21">
          <key name="sub_sub_211"/> 
        </key> 
        <key name="sub_sub_21"/>
        </key>
      <key name="more_sub_keys"/>
    </key>
  </admin-texts>
</wpml-config>

Please note that the wildcard * does NOT work in parent keys:

The wildcard does not work in parent keys
<wpml-config>
  <admin-texts>
    <key name="some_option_*" />
    <key name="*"/>
  </admin-texts>
</wpml-config>

Additional Resources

To learn more about the wpml-config.xml file, visit the Language Configuration Files guide.

For customizing other elements using the wpml-config.xml file, visit our additional guides: