If you create the multilingual website application using PHPMaker 9.0.1, 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.
Updated on May 30, 2012: This customization has been implemented in PHPMaker version 9.0.2, it matches to each other, and as a result, it works properly.
Updated on July 22, 2012: This customization has been implemented in PHPMaker version 9.0.3, it matches to each other, and as a result, it works properly.
Updated on September 5, 2012: This customization has been implemented in PHPMaker version 9.0.4, it matches to each other, and as a result, it works properly.
Updated on November 28, 2012: This customization has been implemented in PHPMaker version 9.1.0, it matches to each other, and as a result, it works properly.
Updated on February 9, 2013: This customization has been implemented in PHPMaker version 9.2.0, it matches to each other, and as a result, it works properly.
Updated on June 17, 2013: This customization below has been handled by using MasinoFixedWidthSite extension. You donβt need to implement the customization below if you use my extensions together with the original PHPMaker Template and Extension files.
[hidepost]
-
First of all, we have to rename all the .txt files that located in the \Script 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
- registeren.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
- registerid.txt
afterwards, translate the content of that files except for the code that will be interpreted by PHPMaker. So, be careful!
Please note that for register file, the filename does not contain "-" character. The reason for this since PHPMaker will cause an error while generating the cache files related to register text file if the text filename contains "-" character.
-
Open your \Script\control.xml file, and find this code:
<!-- Text files --> <control id="forgotpwd.txt" type="copy" remark="Copy forgotpwd.txt" ofolderid="_txt" ifiles="forgotpwd.txt" /> <control id="changepwd.txt" type="copy" remark="Copy changepwd.txt" ofolderid="_txt" ifiles="changepwd.txt" /> <control id="notify.txt" type="copy" remark="Copy notify.txt" ofolderid="_txt" ifiles="notify.txt" /> <!-- register text --> <control id="register.txt" type="other" ofolderid="_txt" ofile="register" oext="txt" space="False" ifiles="register.txt" cond="proj/SecRegisterPage/EQ/True,proj/SecType/EQ/Use Table|Both"> <session type="key" value="registeremail" /> </control>
then replace it with the following code:
<!-- Text files --> <control id="requestpwd-en.txt" type="copy" remark="Copy requestpwd-en.txt" ofolderid="_txt" ifiles="requestpwd-en.txt" /> <control id="requestpwd-id.txt" type="copy" remark="Copy requestpwd-id.txt" ofolderid="_txt" ifiles="requestpwd-id.txt" /> <control id="forgotpwd.txt" type="copy" remark="Copy forgotpwd.txt" ofolderid="_txt" ifiles="forgotpwd.txt" /> <control id="changepwd.txt" type="copy" remark="Copy changepwd.txt" ofolderid="_txt" ifiles="changepwd.txt" /> <control id="notify.txt" type="copy" remark="Copy notify.txt" ofolderid="_txt" ifiles="notify.txt" /> <control id="forgotpwd-en.txt" type="copy" remark="Copy forgotpwd-en.txt" ofolderid="_txt" ifiles="forgotpwd-en.txt" /> <control id="changepwd-en.txt" type="copy" remark="Copy changepwd-en.txt" ofolderid="_txt" ifiles="changepwd-en.txt" /> <control id="notify-en.txt" type="copy" remark="Copy notify-en.txt" ofolderid="_txt" ifiles="notify-en.txt" /> <control id="forgotpwd-id.txt" type="copy" remark="Copy forgotpwd-id.txt" ofolderid="_txt" ifiles="forgotpwd-id.txt" /> <control id="changepwd-id.txt" type="copy" remark="Copy changepwd-id.txt" ofolderid="_txt" ifiles="changepwd-id.txt" /> <control id="notify-id.txt" type="copy" remark="Copy notify-id.txt" ofolderid="_txt" ifiles="notify-id.txt" /> <!-- register text --> <control id="register.txt" type="other" ofolderid="_txt" ofile="register" oext="txt" space="False" ifiles="register.txt" cond="proj/SecRegisterPage/EQ/True,proj/SecType/EQ/Use Table|Both"> <session type="key" value="registeremail" /> </control> <control id="registeren.txt" type="other" ofolderid="_txt" ofile="registeren" oext="txt" space="False" ifiles="registeren.txt" cond="proj/SecRegisterPage/EQ/True,proj/SecType/EQ/Use Table|Both"> <session type="key" value="registeremail" /> </control> <control id="registerid.txt" type="other" ofolderid="_txt" ofile="registerid" oext="txt" space="False" ifiles="registerid.txt" cond="proj/SecRegisterPage/EQ/True,proj/SecType/EQ/Use Table|Both"> <session type="key" value="registeremail" /> </control>
-
Open your \Script\share-script.php file, and find this code:
$sFn = "<!--##=sFnNotifyTxt##-->";
then replace it with the following code:
// Begin of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012 $sFn = str_replace('notify.txt', 'notify-'.$GLOBALS["Language"]->LanguageId.'.txt', '<!--##=sFnNotifyTxt##-->'); // End of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012
-
Open your \Script\update-script.php file, and find this code:
$sFn = "<!--##=sFnNotifyTxt##-->";
then replace it with the following code:
// Begin of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012 $sFn = str_replace('notify.txt', 'notify-'.$GLOBALS["Language"]->LanguageId.'.txt', '<!--##=sFnNotifyTxt##-->'); // End of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012
-
Open your \Script\changpwd.php file, and find this code:
$Email->Load("<!--##=sFnChangePwdTxt##-->");
then replace it with the following code:
// Begin of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012 $Email->Load(str_replace('changepwd.txt', 'changepwd-'.$GLOBALS["Language"]->LanguageId.'.txt', '<!--##=sFnChangePwdTxt##-->')); // End of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012
-
Open your \Script\forgotpwd.php file, and find this code:
$Email->Load("<!--##=sFnForgotPwdTxt##-->");
then replace it with the following code:
// Begin of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012 $Email->Load(str_replace('forgotpwd.txt', 'forgotpwd-'.$GLOBALS["Language"]->LanguageId.'.txt', '<!--##=sFnForgotPwdTxt##-->')); // End of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012
-
Open your \Script\register.php file, and find this code:
$Email->Load("<!--##=sFnRegisterTxt##-->");
then replace it with the following code:
// Begin of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012 $Email->Load(str_replace('register.txt', 'register'.$GLOBALS["Language"]->LanguageId.'.txt', '<!--##=sFnRegisterTxt##-->')); // End of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012
-
Open your \Script\audittrail.php file, and find this code:
// Send email after add success function SendEmailOnAdd(&$rs) { global $Language; $sFn = "<!--##=sFnNotifyTxt##-->";
then replace it with the following code:
// Send email after add success function SendEmailOnAdd(&$rs) { global $Language; // Begin of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012 $sFn = str_replace('notify.txt', 'notify-'.$GLOBALS["Language"]->LanguageId.'.txt', '<!--##=sFnNotifyTxt##-->'); // End of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012
-
Still in that \Script\audittrail.php file, and find this code:
// Send email after update success function SendEmailOnEdit(&$rsold, &$rsnew) { global $Language; $sFn = "<!--##=sFnNotifyTxt##-->";
then replace it with the following code:
// Send email after update success function SendEmailOnEdit(&$rsold, &$rsnew) { global $Language; // Begin of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012 $sFn = str_replace('notify.txt', 'notify-'.$GLOBALS["Language"]->LanguageId.'.txt', '<!--##=sFnNotifyTxt##-->'); // End of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012
-
Open your \Script\list-script-function.php file, and find this code:
<!--## if (TABLE.TblSendMailOnEdit) { ##--> // Send notify email $sFn = "<!--##=sFnNotifyTxt##-->";
then replace it with the following code:
<!--## if (TABLE.TblSendMailOnEdit) { ##--> // Send notify email // Begin of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012 $sFn = str_replace('notify.txt', 'notify-'.$GLOBALS["Language"]->LanguageId.'.txt', '<!--##=sFnNotifyTxt##-->'); // End of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012
-
Still in that \Script\list-script-function.php file, and find this code:
<!--## if (TABLE.TblSendMailOnAdd) { ##--> // Send notify email $sFn = "<!--##=sFnNotifyTxt##-->";
then replace it with the following code:
<!--## if (TABLE.TblSendMailOnAdd) { ##--> // Send notify email // Begin of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012 $sFn = str_replace('notify.txt', 'notify-'.$GLOBALS["Language"]->LanguageId.'.txt', '<!--##=sFnNotifyTxt##-->'); // End of modification Email Template based on Selected Language, by Masino Sinaga, May 4, 2012
- Finally, re-generate your script files using PHPMaker as always.
[/hidepost]
keithh0427 says
It appears that in Step 6, if we have already implemented modification Activate Password, by Masino Sinaga, May 31, 2012, then the code to find and replace is missing
Masino Sinaga says
Yes. Therefore, I suggest you to implement the customization based on the order by Date smaller first.
keithh0427 says
Masino, That’s exactly what I do. Earliest date to latest date.
I was just curious why there is no reference to a forgotten password in this customization. The earlier customization removes the code: $Email->Load(““); so that it cannot be replaced here.
That’s why I’m curious. Why is there no customization to send an email for a forgotten password?
Masino Sinaga says
Because this customization “How to Use Email Template Based on the Selected Language in Websites that Created with PHPMaker 9.0.1” (May 20, 2012) is the earlier one than the other “How to Add Request Password Confirmation into Websites that Generated with PHPMaker 9.0.2” (June 2, 2012).
That is why you did not see the reference to a forgotten password in the customization in this article. In fact, you will see the reference to this article from the other article “How to Add Request Password Confirmation into Websites that Generated with PHPMaker 9.0.2” (June 2, 2012). As we can see step number 6 in the other article, will refer to this article.
Does it make sense for you now? π
keithh0427 says
Masino,
the instruction indicate: Please note that for register file, the filename does not contain β-β character.
Yet, in step 7, you are using “register-”
Am I confused?
Masino Sinaga says
Good catch. I just fixed it. Thanks.