Multilingual Sites: WPML and Polylang

Results in the language of the visitor

On a site translated with WPML or Polylang, the search page shows results in the language the visitor is browsing in. A visitor on the German side of your site gets German pages. There is nothing to switch on: it works as soon as one of the two plugins is active.

How each page gets its language

  • The plugin prints the locale of the page (for example de_DE) in the head of every page of your site. The Data Crawler reads it and stores it with the page.
  • Documents with no locale of their own, such as many PDFs, are kept under the language Opensolr detects in their text: Language and locale.

How results are kept in one language

  • When the visitor's locale has a country part (de_DE), results must carry exactly that locale.
  • When it has none, every country of that language matches.
  • Documents without a locale match when their detected language is the visitor's language.

Suggestions under the search box follow the same rule.

Translations in the sitemap

For every post, the plugin sitemap lists the addresses of its translations, so the crawl finds every language of your site: The plugin sitemap.

Data Ingestion on a translated site

Data Ingestion does not read the WPML or Polylang language of a post: every post it sends carries the locale WordPress reports at that moment. To give each translation its own language, index your translated content with the Data Crawler.