Polylang is a popular plugin that enables you to create a multilingual WordPress site. When combined with Sensei LMS, it can be used to serve different versions of course content depending on which language the visitor has selected.
There are a couple of things to be aware of before proceeding with Polylang:
- You will need to recreate your menus, one per language. Until that is done, no menus will be visible on your site after installing Polylang.
- Polylang does not automatically translate content for you. If you like, you can use an additional plugin called Lingotek Translation to help with that. Lingotek provides the option to do machine translation of your content (up to 100,000 characters is free), or you can pay to have it professionally translated.
Configure Polylang to Work With Sensei LMS
In this tutorial, we’ll assume that we’ve already created a course and some lessons in English, and we want to translate them to Spanish.
Polylang Installation & Setup
- Start by installing Polylang.
- Proceed through the setup wizard. In the first step, we’ll select English and Spanish as the languages and then click Continue:
- Toggle whether or not you’d like to translate media and click Continue.
- The next step is where we select the default language that our content has been written in. In our case, since we’ve already written our course and lessons in English, that’s the language we’ll select here:
- The setup wizard is complete and we can now exit to the dashboard.
An unfortunate side effect of activating Polylang is that it requires you to recreate your site menus. You will need to create one menu for each language you selected in the wizard. In our case, we would need to create an English menu and a Spanish menu. You can learn how to do that in the Polylang documentation.
Add a Language Switcher
To enable your visitors to switch to a different language, you will need to add a language switcher to your site. You can either add it to an existing menu or as a widget. There is more information on how to do this in the Polylang documentation.
The final step is to translate your content. As mentioned previously, Polylang on its own does not automatically translate your content. You can install Lingotek to leverage machine translation, but if you have a lot of content or the quality of the translations are important, there will be a cost.
The easiest way to create a translated version of an existing course is to open the course in the editor. In the Languages box in the sidebar, click the + icon beside the language you would like to create a translation for. In our case, that’s Spanish:
This will create a new course, with the Language setting already correctly set to the translated language. You can now get to work translating the course, and then repeat this process for lessons, questions or any other type of content you’d like to translate. When translating lessons, don’t forget to assign it to the translated course!
Now when you visit your site and select a different language using the language switcher, the page will update to show the translated content.
If you find that you are getting 404 Page Not Found errors when clicking links (for example, clicking on a lesson in a course), try going to Settings > Permalinks and clicking the Save Changes button, without actually making any changes. This should be enough to resolve the 404s.
Otherwise, Polylang has some of its own URL modification settings you can explore.
If you notice that some of your courses are no longer appearing on your site, the most likely culprit is that the default language of those courses was not set correctly. Here’s what you can do to fix it:
- Go to Courses > All Courses.
- In the language switcher that appears in the top toolbar, ensure Show all languages is selected:
- If you do not see a language flag in the table for every course, it means that course is no longer visible on your site, so we need to fix that right away. Click on the bulk select box at the top of the course list to select all courses on the page, or check the box beside each course that is missing a flag. Then choose Edit from the dropdown:
- Click Apply and then choose the appropriate language from the Language dropdown. Click Update to save your changes:
- The default language flag should now be displayed for all courses. Repeat the above steps, if necessary, for lessons, pages and any other type of content you may have on your site.