If you are using WPML, Polylang or Polylang Pro, download and install the Multilingual add-on to integrate your translations with FacetWP.

WPML

The Multilingual add-on supports normal translations, as well as dynamic strings (e.g. facet placeholder text) via the WPML String Translation plugin.

The add-on supports sub-site (fr.mysite.com) and sub-directory (mysite.com/fr/) permalinks, but does not support URL strings (?lang=fr).

WPML translation setup

In order for WPML to work well with FacetWP, you need to correctly set up the Post Types Translations and Taxonomies Translations in WPML’s settings. Go to:

WPML > Settings > Multilingual Content Setup

Then scroll down to the “Post Types Translation” and “Taxonomies Translations” tables.

For each post type and taxonomy that you are using in post listings with facets, make sure you select the first option: “only show translated items”:

WPML Post Types and Taxonomies Translation setting - Select Only show translated items. Do not use the second (fallback) option!
WPML Post Types and Taxonomies Translation setting – Select “Only show translated items”. Do not use the second (fallback) option!

Then, in WPML > Translation Management and WPML > Taxonomy translation, make sure every item has a translation. Or you can use the bulk edit feature to create duplicates for all items, for as long as the content is not translated yet.

The second option, “use translation if available or fallback to default language”, does not work well with FacetWP. If you select that option and you have posts without a translation, you will have the fallback (original language) posts in the translated language results, and those posts will have their (original language) categories/terms indexed. This will result in duplicate categories/terms showing up in facets: in the translated language and in the original language.

Keep in mind that when FacetWP indexes a post, it determines that post’s language and indexes any related content for that language. FacetWP does not support the concept of a single post belonging to multiple languages, so you essentially need to have a translated post for each language. If a translation is not available, you need to duplicate the post in the original language.

If you are using (ACF) custom fields as data source for your facet, make sure that those fields are set to be translatable, and are translated for each post in each language.

Solving issues with WPML

If you encounter any issues with WPML, like posts, terms or other data not appearing, make sure your WordPress install has enough memory. WPML’s minimum requirements are 128M, and 256M is recommended.

In our performance tuturial you can read how to give WordPress more memory.

You can see how much memory is currently set by going to WPML > Support. In the WordPress section, you’ll see what is set as WordPress’ memory limit. This has to be lower or equal to what is available on the server, which you can see in the PHP section under “Memory limit”.

If you go to WPML > Support > Troubleshooting, you’ll see a lot of buttons with which you can clean up WPML’s cache and database. Make sure you have a database backup before using that.

Polylang

The Multilingual add-on supports normal Polylang translations.

Polylang Pro shared slug feature

Polylang Pro comes with a feature that makes it possible for posts, pages or terms to share the same slug across translations.

Currently, this feature does not work with FacetWP. With shared slugs, on pages with the non-default language facets will not return expected options.

The solution for now is to use unique slugs across translations.

Translating dynamic strings with the facetwp_i18n hook

FacetWP has a set of strings that cannot be translated with __() or _e(), because these strings are dynamic, “in-database” strings, which WPML or Polylang cannot access. These strings are mostly labels used in various facet types.

Fortunately, there is a way to translate these strings: with the facetwp_i18n hook.

Using WPML or Polylang with SearchWP

If you are using SearchWP on a multilingual site with WPML or Polylang, make sure to install the appropriate SearchWP integration extension:

These extensions will limit search results to the active language of the page. Without them, there will be a disconnect between the facets, their counts and the post listing.

Indexing errors with Polylang or WPML installed

When you have Polylang or WPML installed without the Multilingual add-on, you can get a “The index table is empty” error when trying to re-index. To fix this, simply install the add-on and re-index.

Changelog

1.0.1

  • Fixed minor code cleanup / modernization

1.0.0

  • Fixed the correct element_type was not being passed into WPML (props Bram)

0.2.2

  • Fixed reset WPML language after indexing
  • Fixed make sure Polylang language variable is defined

0.2.1

  • Fixed WPML class name (props Derrick Hammer)

See also