Sending User
emails in the users
preferred language
Anyone who has built a multilingual Drupal site is aware that things aren't always as straight forward as you might hope.
We usually get there in the end using a few essential modules i18n, l10n client and string overrides plus a variety of other useful modules for those harder to reach areas.
One area which caused me some brain ache was the translation of the user emails found admin/user/settings. When a user registers whose language is different to that of the site default language she should receive her welcome email in her native language, but this isn't automatically the case. In my case I have the default language set to English, with French imported and enabled.
We have to address two issues to solve this problem.
User can't specify language during registration process.
By default, regardless of the language the user is viewing the site in when she registers, her language preference is set to the site default during the registration process. If she wants to specify an alternative language she must visit user/UID/edit after the registration process is complete.
By this time Drupal has already sent out a welcome email in the site default language.
Kars-T has come up with a great module addresses this, Registration language. It can be configured that if our user is browsing the site French when she registers her language preference is automatically set to French, she can always modify this later at user/UID/edit.
The site emails are not multilingual variables.
In the same way that we can make the site name, frontpage, mission statement etc multilingual variables, we can do the same for all the text areas concerning site emails admin/user/settings.
You either need to create or add to the array $conf['i18n_variables'] in your /sites/default/settings.php file. If you don't already have this array in your setting.php just copy the whole chunk into the bottom, if you already have it just add the extra lines relating to user_mail.
-
$conf['i18n_variables'] = array(
-
// Site name, slogan, mission, etc..
-
'site_name',
-
'site_slogan',
-
'site_mission',
-
'site_footer',
-
// User email variables
-
'user_mail_password_reset_body',
-
'user_mail_password_reset_subject',
-
'user_mail_register_admin_created_body',
-
'user_mail_register_admin_created_subject',
-
'user_mail_register_no_approval_required_body',
-
'user_mail_register_no_approval_required_subject',
-
'user_mail_register_pending_approval_body',
-
'user_mail_register_pending_approval_subject',
-
'user_mail_status_activated_body',
-
'user_mail_status_activated_subject',
-
'user_mail_status_blocked_body',
-
'user_mail_status_blocked_subject',
-
'user_mail_status_deleted_body',
-
'user_mail_status_deleted_subject',
-
'user_picture_guidelines',
-
'user_registration_help',
-
);
Once you have added this code you just need to visit admin/user/settings in each language and edit the emails to suit the current language (you may find that you need to re-enter the details for the default language as sometimes they get over written the first time you add the other language versions)
That's it, now all users will receive their registration email and all future emails in their preferred language.
Thanks
Thanks a ton simon for this useful post, it really helped to solve this problem quickly without wandering here n there.
Forgot to mention my name
I forgot to mention my name in above comment and now cannt edit it as it is submitted by name of anonymous user. Well, i m Varun Taliyan(varuntaliyan@gmail.com)