If you create the multi language website application using PHPMaker, then you will find that by default your web site will send an email using the English email template to the user regarding the event your user have just done, even the user has selected non English language before. This could be happened since PHPMaker has not handled the email templates that support for multilanguage, yet. So we will handle this situation by customizing the generated files that using those email templates.
For example, your site supports for English and Indonesian languages. When your user select Indonesian, and the user forgot the password, then they will request or reset the password, afterwards that site will send the password to the user's email using the English email template. This also can be happened for the other event such as registration and change password. Of course, this is not the proper condition we want. That site should send an email in Indonesian (not in English) since that user has selected the Indonesian language before asked for the password.
So, this customization below will solve the problem. After implementing it, then your user will get an email content based on the selected language they chosen. If they chose English, then they will get emails in English. If they chose Indonesian, then they will get emails in Indonesian. This will more make sense. Generally, this email template are needed for registration, forgot password, and change password process. If you implement the audit trail in your site, then you should also do the same modification to all the generated files regarding this audit trail process.
[hidepost]
In this case, we have to modify the generated files, and not customizing the template as most we have done so far.
-
First of all, we have to rename all the .txt files that located in the /phptxt sub directory. Add the English language code as the suffix to the filename. So they all will become like this:
- changepwd-en.txt
- forgotpwd-en.txt
- notify-en.txt
- register-en.txt
-
Secondly, copy all those four files and rename it by adding the language code suffix based on the other languages you use. In that example above, we will rename it to become as following:
- changepwd-id.txt
- forgotpwd-id.txt
- notify-id.txt
- register-id.txt
afterwards, translate the content of that files except for the code that will be interpreted by PHPMaker. So, be careful!
-
Open your forgotpwd.php file (remember that this is the generated file, and not the template file), and find this code:
$Email->Load("phptxt/forgotpwd.txt");then replace it with this following code:
$Email->Load("phptxt/forgotpwd-" . $GLOBALS["Language"]->LanguageId . ".txt"); -
Open your register.php file, and find this code:
$Email->Load("phptxt/register.txt");then replace it with this following code:
$Email->Load("phptxt/register-" . $GLOBALS["Language"]->LanguageId . ".txt"); -
Open your changepwd.php file, and find this code:
$Email->Load("phptxt/changepwd.txt");then replace it with this following code:
$Email->Load("phptxt/changepwd-" . $GLOBALS["Language"]->LanguageId . ".txt");
[/hidepost]
Leave a Reply
You must be logged in to post a comment.