[SalesForce] Multi-lingual Visualforce email templates

I have a requirement where on workflow rules I want to send out an email in the users preferred language, Is there a way to create multi-lingual visualforce email templates?

here is the sample Visualforce email template:

<messaging:emailTemplate recipientType="User"
    relatedToType="custom_object"
    subject="Case report for Account: {!relatedTo.name}">

    <messaging:htmlEmailBody>
        <html>
            <body>

            <p>Dear {!recipient.name},</p>
            <p>Below is a list of cases related to {!relatedTo.name}.</p>
            <table border="0" >
                <tr>
                    <th>Case Number</th><th>Origin</th>
                    <th>Creator Email</th><th>Status</th>
                </tr>

            </table>
            <p/> 
            </body>
        </html>
    </messaging:htmlEmailBody>
</messaging:emailTemplate>

So wherever, you see the English text that should be translate to different language based on the user selected language perference.

sample workflow rule selecting the above email template:

enter image description here

Best Answer

After doing some research I able to figured out how to achieve this, if someone has better way of doing please post it here.

1) I modified my VF email template and added attribute language="{!recipient.LanguageLocaleKey}"

2) After doing that, I created Custom Labels as shown below:

enter image description here

3) After creating the Custom Labels I just had to plug them in the VF email template as shown below.

<messaging:emailTemplate recipientType="User" language="{!recipient.LanguageLocaleKey}"
    relatedToType="custom_object"
    subject="Case report for Account: {!relatedTo.name}">

<messaging:htmlEmailBody>
    <html>
        <body>

        <p>{!$Label.Translation_Custom_Label_Line_1} {!recipient.name},</p>
        <p>{!$Label.Translation_Custom_Label_Line_2} {!relatedTo.name}.</p>
        <table border="0" >
            <tr>
                <th>{!$Label.Translation_Custom_Label_Line_3}</th> 
                <th>{!$Label.Translation_Custom_Label_Line_4}</th> 
            </tr>

        </table>
        <p/> 
        </body>
    </html>
</messaging:htmlEmailBody>

4) If you want to test it out, go back to the User account change the Language and Save the record, then go back to the Email Template and do a Send Test Email

It works fine without any issue, again if you have a better solution please let me know and hope this will help others.

Related Topic