Sensei makes it possible to create and sell online courses, lessons and quizzes. A big part of this is sending notification emails to the members. WPML 3.4 and the upcoming Sensei version allow you to send notification emails to each user in the right language.
WPML 3.4 introduces a new mail api, which is the basis for this new development. It allows themes and plugins to remember the preferred language of each user and switch to that language before sending emails.
Language selection for site members
It all begins by allowing site members to choose their preferred language.When the users register on the website, they will have the option to choose their prefered language from their admin panel.
Translating the emails
Sensei sends predefined email notifications to both learners and the teachers. You have the option to choose which email notifications that will be sent.
As an example we will translate the notification email sent to the teacher when their students submit a quiz, this can be achieved by using the string translation module in 4 easy steps:
- Navigate to WPML > Theme and plugins localization.
- Choose the “Translate the theme and plugins using WPML’s Translation” option.
- Scan Sensei plugin for translatable strings by choosing it and clicking on the “Scan the selected buttons for strings”.
This is the email template sent to the teacher, we will navigate to the String Translation page to translate its strings.
- Navigate to WPML > String translation and search for the string “has submitted the quiz for lesson”.
- Click on the “translations” link and add the translated text, choose “Translation is complete” and click on the save button.
Note that, all the email strings can be translated by following the same steps.
You can customize these emails further (edit the email body), navigate to the Sensei template folder found in the plugin directory (wp-content>plugins>sensei>templates>emails) and open the email template you wish to edit. In the screenshot below you can see the notification email template of the student submitting a quiz to the teacher, with the editable strings marked.
Sending localized emails
Let’s go over a quick example of how Sensei will be sending localized emails. When a French student clicks on “Start Taking This Course” button and the owner of this course is a German teacher. Sensei will be sending two notification emails:
- An email to the teacher, thanking him for joining (Sent in French)
- Another one to the Teacher, Notifying him that a new teacher is enrolled into his course (Sent in German)
WPML’s new API kicks in. Just before Sensei gets the email subject and body, it switches the language to the user’s language. When it loads the email subject and content from the database, WPML automatically replaces with the translation. As a result, each of the site’s members will receive an email in his or her language and not in the admin’s language.
Want to try it on your multilingual Sensei site?
To send localized emails with Sensei, you will need to use WPML 3.4 (with String Translation) and the upcoming version of Sensei. Since Sensei is a paid plugin, we can only send you this development version of Sensei if you already bought Sensei. Leave us a comment, saying that you’re interested. We’ll get in touch, verify your Sensei purchase and send you the dev version, with this integration.