I'm trying to use a Visualforce Email Template to translate content into another language. Even if I hard-code the language, when I click "Send Test & Verify Merge Fields", the email does not get translated.

I have set up the French language in the Translation Settings and made sure it is activated. Is there another setting or piece of setup that I'm missing?

Thanks in advance!

Here is my Visualforce code:

<messaging:emailTemplate subject="Test VF Template" recipientType="Contact" relatedToType="Innovation__c" language="fr">
<messaging:plainTextEmailBody >

   Dear {!relatedTo.Applicant_Name__c},
   This should all be in French. But its not.


The language attribute just sets the language of the email with regards to labels.
It doesn't mean that it will take this specific template if the recipient language is French.

You need to create Custom Labels for the text you want to have translated. You can then set translated values for each of the languages that you support in those labels. In your example then the French value will be displayed.

You can also make it dynamic based on the language of the recipient with something like this:

<messaging:emailTemplate recipientType="Contact"
    replyTo="cases@acme.nomail.com" >

    <messaging:htmlEmailBody >
        <p>{!$Label.email_greeting} {!recipient.name}--</p>


This takes a custom field on Contact, language__c, which contains language keys like fr, en, de etc.



You can use parameters in your label. This way you don't need 2 labels in your example, one for 'Dear' and one for the rest of the text, but just 1.
If you define your label as 'Dear {0}, This should all be in French. But its not.', you can then use the following code to merge the {!relatedTo.Applicant_Name__c} into the label like this:

<apex:outputText value="{!$Label.YourLabelName}" >
    <apex:param value="{!relatedTo.Applicant_Name__c}" />
  • Thanks @Folkert. That's disappointing to hear since I need to find a way to translate 30+ email templates into 3 different languages, so creating custom labels for all the content is not feasible nor sustainable. Any thoughts on using a custom object to store records of the email content and translating that some how? Or any other suggested approaches for solving for this problem? – JustinF May 28 '18 at 17:01
  • @JustinF Yea, it can be a pain to maintain them all, but there are some tricks to make your life easier. I'll update the answer. – Folkert May 29 '18 at 7:37
  • I had similar challenge/frustration recently - namely getting my custom label translations to work for each email using a dynamic language variable in the visualforce component. Here's my solution for my situation in case helpful: salesforce.stackexchange.com/a/337663/43223 – Christopher D. Emerson Mar 23 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.