WPML, a plugin for handling multilingual content in WordPress, has the ability to read an XML file for its configuration. In this language configuration file, we can define which custom fields, custom post types, taxonomies and admin texts we want translatable in our theme.
I’ve been using a WooThemes commercial theme for a client, but ran in to a problem when trying to translate the footer. The theme allows the user to add custom content for the footer through a text field in its options panel; this text is therefore not wrapped in any gettext function, blocking WPML from hooking in to it automatically.
The problem was solved by adding the following (saved as wpml-config.xml
) to the root of the parent theme folder:
<wpml-config> <admin-texts> <key name='woo_options'> <key name='woo_footer_left_text' /> <key name='woo_footer_right_text' /> </key> </admin-texts> </wpml-config>
This file tells WPML to make the values of the two listed keys into translatable strings, to be found under WPML → String Translation. woo_options
is the name of the option (itself an array) containing the needed values.
wpml-config.xml
provides a clean, simple way to define translatable strings for the often troublesome elements of a theme; ask your commercial theme providers to provide these configuration files with all of their themes.
and then ? what do I put in the code ?
I mean if I define woo_footer_left_text , what to put in the theme php files ?
thanks
Just echo out the option as you normally would, and WPML will provide the correct string:
[php]
echo esc_html( $woo_options[ ‘woo_footer_right_text’ ] );
[/php]
Hey Kirk – thanks for posting this solution to Canvas not wrapping the footer custom text in gettext. I’m rebuilding my own multilingual site (teaching English) using Canvas and find it and WPML very good, but there are always snags along the way. I managed to carefully edit in what you suggested into my wpml-config.xml file and then rescanned with for strings with WPML and up popped my footer text. I’m not a developer, just an enthusiast of necessity here in Dublin. – rgds, Todd (fluidenglish.com new site will be up and running hopefully in the coming weeks)