How to Launch a Multilingual Site on WordPress
Introduction
In this article, we review the execution and deployment of a multilingual site based on WordPress with the help of the Polylang Pro plugin. Burns & Wilcox (a privately owned insurance company based in the US) approached us with an existing site for the US running on WordPress and was interested in launching a Canadian site that would support both English and French. They needed a Canadian site as well that inherits most of the functionality of the US version while being able to manage content separately. A multilingual site can be launched by configuring Polylang Pro, creating multilingual content, and Setting up ACF, DevOps, and Analytics.
Establishing the Multilingual Architecture
The US site ran on the latest WordPress 5.4 instance deployed on WPEngine.
WP Admin:
WPEngine Console
The Execution Process
We recommend PolyLang Pro plugin for building a multilingual site that offers advanced features like separate domain (or sub-domain) setup, a consistent URL structure and browser language detection. Stepping up with:
- Step 1: PolyLang Configuration
- Step 2: Creating Multilingual Content
- Step 3: ACF Setup
- Step 4: DevOps
- Step 5 : Analytics
PolyLang Configuration:
Domain settings:
Creating Multilingual Content:
With PolyLang we can easily setup content translation into other languages. First step is to setup a default language in PolyLang configuration. In language settings, a star(*) indicates default language.
3. ACF Setup:
Advanced Custom Fields or ACF is further used to extend some core functionality of WordPress content and the overall site features. Using ACF we were able to create number of field groups and global settings pages. It also enabled creation of field groups based on current and default language detection, isolating content and site related configuration built right into ACF.
More complex implementation for an options page that should be different for each language requires some additional code level filters as shown below, ACF doesn’t seem to provide this feature out-of-the box.
4. DevOps
A careful deployment is paramount when launching multilingual sites with so many plugins, configurations and code level changes. To keep it simple we’ve outlined few crucial steps that should make the process smooth:
- Test multilingual setup with dummy/sub domains: This step is critical before launch because during launch, you may get errors and sometimes domain setup might not work as expected in PolyLang. It depends on your server configuration and domain setup.
Different domain setup errors: Whenever you add different domains in PolyLang settings, you might encounter unexpected errors. Don’t panic, just solve them one by one. If you still see errors like below, safely ignore them and test your site further.
Language detection/redirect:
In a different domain setup you might not face any critical issues, but they might creep up when default language detection is turned on in PolyLang. This detection can mix up language settings, like when a user’s browser is set to default locale like en/GB or en/DE. A simple workaround is to disable the default language detection in PloyLang.
- Domains replacement in different environments: If you use multiple environments like development, stage, or production, than you should set up different domains or sub-domains for each. Even though the push happens from stage to production, you should replace stage URLs with production URLs for other language domains. Then the primary domain automatically changes during push. Using a search and replace plugin or WP-CLI should do the job for you.
5. Analytics: A multilingual site may require different analytics configuration all of which can be managed in language specific files as below:
Summary
It may seem relatively easy to setup and deploy multilingual sites in Wordpress, it’s the nitty-gritty details that matter the most. Summing it up in four crucial steps:
- Careful setup of multilingual sites in PolyLang
- Testing your setup thoroughly with sub domains before going live
- Keep an extra eye out on deployment while doing regular pushes
- Weekly site checkups
If you follow these disciplines religiously, you should be able to work your way around setup and deployment with ease. Happy coding!