Plugin: Polylang

Plugin: Polylang

There is also a free, easy to use, and very light-weight plugin called Polylang. Migration from WPML to Polylang should be painless with dedicated plugin WPML to Polylang by PolyLang creators.

Polylang Pro is required for ACF Pro compatibility, as stated in official document. They also recommend to use third-party plugin to translate ACF options: ACF Options For Polylang

Not sure if Pro is really required as some users are stating that “ACF works great with Polylang and everything works out of the box as expected. No dirty hacks are needed, except for “options” page.”

For CF7, if you don´t want to create a form for each language, you can use one single CF7 form for all languages using plugin Multilingual Contact Form 7 with Polylang

For “String translation” Polylang officialy suggests using any PO/MO tools: How to translate the themes and plugins hardcoded strings?, but there is an extension: Theme and plugin translation for Polylang (TTfP) that does exactly that ans makes wonders.


Using Polylang without paying for Pro

If you need proper Woocommerce, I guess you must buy it. But for everything else, free is sufficient.

grappler/polylang-slug

When we say “same slug” we mean that /wizard, /nl/wizard and /de/wizard are the same. Even official Polylang Pro mentions polylang-slug project inside code.

Differences of Pro vs Free:

  • Premium support Don’t need it

Amazing additions to the plugin

Essential

Very Good

Interesting


How to remove Polylang plugin

Quite nice and possible.

https://polylang.pro/doc/is-polylang-compatible-with-the-eu-cookie-law/

PLL_COOKIE If you prefer a cookie expiring at the end of the session, ad this in a custom plugin or a child theme: add_filter( ‘pll_cookie_expiration’, function() { return 0; } ); https://wordpress.org/support/topic/any-way-to-disable-pll_cookie-without-changing-wp-config-php/

Nginx Cache and Polylang problem

Nginx fastcgi_cache and Polylang homepage redirect | WordPress.org https://pantheon.io/docs/plugins-known-issues#polylang

Polylang options: List of options which can be set in wp-config.php | Polylang

https://docs.wp-rocket.me/article/76-using-translation-multilingual-plugins


Polylang and WP-CLI

Polylang stores language information as a taxonomy ‘language’ for posts and ‘term_language’ for terms.

In WP-CLI we can use https://github.com/diggy/polylang-cli, but without it, we can use:

To list languages:

wp term list language

List English pages

wp post list --post_type=page --lang=en

or:

wp post list --post_type=page --lang=nl --fields=ID,post_title

Using SQL to modify Polylang data

Source: Search and replace query with multilanguage site (polylang)

List all English pages

1
2
SELECT id, post_title FROM `wp_posts` WHERE post_type = 'page' AND id IN (
    SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(`description`, '"en";i:', -1), ';',1) FROM `wp_term_taxonomy` WHERE `taxonomy` = 'post_translations' )

Do a basic search-replace on one language, for example nl for Dutch

1
2
3
4
5
6
UPDATE `wp_posts` AS a
INNER JOIN (
  SELECT id, post_title FROM `wp_posts` WHERE post_type = 'page' AND id IN (SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(`description`, '"en";i:', -1), ';',1) FROM `wp_term_taxonomy` WHERE `taxonomy` = 'post_translations' )
) AS b
ON a.ID = b.ID
SET a.post_content = replace(a.post_content, '<!-- wp:block {"ref":2323} /-->', '<!-- wp:block {"ref":4247} /-->');

In above query, I’m actually replacing one Gutenberg Reusable Block with another for specific language.


date 15. Jul 2021 | modified 23. Sep 2022
filename: Plugins » Polylang