Translating Custom Fields
WordPress custom fields 101
Custom fields allow creating rich contents using WordPress. Some custom fields are created by plugins or the theme and some created by the user.
For example, our own WPML plugin uses custom fields for its navigation elements. It adds a custom field for the mini-home, section name and exclude-from-navigation settings. Other plugins, like WordPress SEO use custom fields to set the title and description of pages.
Plugins, such as Types, help manage custom fields. They create a fancy GUI and dress custom fields with special functionality. Types works together with WPML to make custom fields fully translatable.
How custom fields get translated by WPML
Since custom fields belong to individual posts or pages, they get translated without having to configure anything. When you create new translation for a post or page, it will already have its own custom fields. So, for instance if you’re using an SEO plugin which sets the title, you will enter one title for the English post and another title for the Spanish post.
This is a different case than translation of global texts which are not part of any post or page (like the site’s title or tagline). Any custom field gets translated without question.
How to include custom fields in ICanLocalize content translation
When your site’s contents are translated using ICanLocalize, WPML packs everything that needs translation and sends to ICanLocalize’s server. For this to happen, WPML needs to know which fields should be sent to translation.
Normally, it sends the page title and body but you can also tell it to translate other fields. To do this, go to the Content Translation screen and look for Plugins texts translation.
If your plugin’s name already appears there, just enable it. Otherwise, you can create this file for yourself and upload it.
Each entry in the file has 5 columns:
- Plugin name
- Field type
- Field name
- Synchronize(0) / translate(1)
Here is an example:
This is the file that comes with WPML for WPML. It tells it to translate the field called _cms_nav_section and to synchronize _top_nav_excluded and _cms_nav_minihome.