Translation

How to translate pages built with Enfold using WPML

Enfold is fully compatible with WPML and you can use WPML to turn your site into a multilingual one in minutes.

You can check out video tutorial below or head over to WPML documentation for more in depth instructions and start translating your site right away!

The tutorial video shows an easy way to translate pages directly from the WPML interface. As an alternative you of course always have the option to create a second page with WordPress and set it as a translation to the first page. This allows more flexibility and you can provide different layout structures for a translation, but lacks the convenience that when you edit the  layout on one page that it also changes on all translations. It’s entirely your choice to decide which method you prefer 😉

New WPML feature, Display as translated

WPML introduces a new translation mode called – display as translated – which is compatible with Enfold and invaluable for developers using Enfold demos.

About the display as translated feature:

  • Users can show original content if no translation is available.
  • Users can display untranslated content without the need to duplicate it anymore.
  • Useful for sites that don’t need to translate everything: listing, directory and membership sites as well as WooCommerce products and taxonomies.

Example:

Let’s say we have a real estate site and we don’t want to translate all the post types belonging to “properties”.

Thanks to this new mode, we can have 98% of our page translated to Spanish but still containing some content in English without duplicating it:

To sum up:

  • If the translation exists = it will display the translation.
  • If the translation does not exist = it will display the post in the site default language.

How to enable this new translation mode for the post types of your choice:

  1. Go to WPML > Translation Management > Multilingual Content Setup
  2. Scroll down to Post Types Translation
  3. Select “Translatable – use translation if available or fallback to original language” option for the post types of your choice.

Child Theme Translations

In case you want to modify something in an Enfold translation you can do it by directly editing the translation file. However, if you update the theme these modifications will be lost. To avoid this, it is recommended to use a child theme approach, here’s how to do it.

Step 1

Create a /lang/ folder in your child theme directory and copy (from the parent theme) the translation files to be modified:

Step 2

Add the following to your child theme functions.php file:

function overwrite_language_file_child_theme() {
    $lang = get_stylesheet_directory().'/lang';
    return $lang;
}
add_filter('ava_theme_textdomain_path', 'overwrite_language_file_child_theme');

Now the translations found in your child theme /lang/ folder will be loaded instead.

Translating the portfolio slug with WPML

Since Enfold 2.4.4 we use the _x() function to translate the portfolio post type slugs. It’s the default (and recommended) solution to translate post type slugs with WPML. Please note that you must install the String Translation extension first – otherwise you can’t translate the slug(s).

After you installed both plugins and Enfold go to the WordPress Dashboard (admin screen) and select “WPML” > “Translation options” from the sidebar menu. A new option page will load – search for the “Translate custom posts slugs (via WPML String Translation).” checkbox and tick it (=activate this setting). Then click the blue “Save” button.

Afterwards search for the “Custom post types” option field on the same option page. It will look like:

Note that you need to tick the checkbox below “Portfolio Items” – otherwise you won’t see the slug translation options for the post type. WPML enables you to translate the slug for each registered language except the standard language. Enter your custom text/translation into the text field(s) and then save the settings.

Eventually select “Settings” > “Permalinks” from the sidebar menu. You’ll notice a “Portfolio Entry Settings” section near the bottom of the permalink option page which enables you to change the slug for the standard language. By default the “Portfolio Items Base” option is set to “portfolio-item” and the “Portfolio Categories Base” is set to “portfolio_entries”. You can replace the default values with some custom text – however you must not use special characters or spaces.

Last but not least save the permalink settings by clicking the “Save Changes” button. Please save the permalink settings even if you didn’t change the default slug rules because the saving process forces WordPress to clear/flush the slug rewrites rules.