Multilingual WordPress: From Frustration to Custom Plugin

Now that my website is running on WordPress, I wanted to offer content in multiple languages. On principle, I believe my website should be available in Dutch – after all, it’s my native language. But since English is the lingua franca of the internet, I also wanted to be able to offer content in English.

Time to look at what was available in terms of WordPress plugins for multilingual websites.

Polylang

After some research, Polylang turned out to be one of the most popular plugins for multilingual WordPress websites. The plugin has a good reputation and appears to be well maintained. Perfect, I thought.

But I soon ran into a problem. While Polylang works well with the classic WordPress editor, support for the modern Gutenberg editor turned out to be less comprehensive. As an example, there was no Gutenberg block that I could use to add a language selection menu to my pages.

For a website running on the latest WordPress version with Gutenberg as the editor, this felt like a missed opportunity.

Doing It Myself

I’ve developed blocks for Gutenberg before, so the basics of creating custom blocks were familiar. The goal was simple: a block that retrieves the available languages of the current page from Polylang and presents them as links that visitors can use to switch between languages.

The Result

After some experimenting and documentation reading, I managed to build a working Gutenberg block that integrates with Polylang’s functionality. You can find the result somewhere on this page.

For people who want to try the plugin themselves: the code and plugin is available at https://github.com/simonmeulenbeek/smb-language-switcher.

Keep in mind that the plugin isn’t fully finished, hasn’t been extensively tested and that bugs and changes will likely occur.

Issues can be reported by creating an issue in the repository. Pull requests are of course also welcome.

Now I can share content in both Dutch and English, without being dependent on the limitations of existing plugins.