Multi-Language Email Templates Using Custom Labels

As you start expanding your Salesforce org, you may find you need to send notifications in multiple languages. In this post, I’ll show how you can do it using Custom Labels. The documentation alludes to using labels, but doesn’t really explain how to do it.

Before we get started, you’ll need to enable Translation Workbench and enable the languages you want to use.

In this example, I’m going to use a field on the record to determine the notification language. Create a picklist field on the object you want to send the notifications from.  Use the new feature available in Spring 17 so you can have a different API name than label as in the screenshot below.

Next, we need to setup some custom labels. In this example, I’m just going to create two custom labels: one for the subject and one for the body. Obviously, you might need many custom labels to support your real email templates. In the subject, you’ll notice I put in a placeholder ({0}). I’m going to use this in the email template to substitute in the record name.

Now that we have the custom field on the object and the custom labels setup, we can create an email template. We have to use a Visualforce email template to get it to work correctly.

Test it with a record with the language field set and you’ll see the template translated.

Implementing this in the real world gets complicated quickly when you want to merge in fields from the source record, combined with different language syntaxes. I attempted to show one technique using a placeholder, but it isn’t easy to use. In my next post, I’ll show another way to do it.


2 thoughts on “Multi-Language Email Templates Using Custom Labels”

Leave a Reply