[SalesForce] How to display a field label in a different language than the current user

I'm using Visualforce to build an email template

Here is a quick insight of my code and what I've tried

get method on my controller

public Contact myContact{
     return [select toLabel(T_Role__c) from Contact where Id=:ContactId];
}

I tried to put the language in the apex page tag

<apex:component access="global" controller="MyController" language="fr">

And in the outputField tag

<apex:outputText value="{!myContact.T_Role__c}" lang="fr" />

But still the value shows in its English translation (Current user language)

Is there a way to specify the language in which the field will be display independently from the running user language?

Best Answer

I would use custom label and Translation Workbench Navigate to : Setup > Translation workbench > Translation settings

Adding Translated Languages and Translators

To add or edit translated languages and translators:

  1. From Setup, click Translation Workbench -> Translation Settings.

  2. Click Add to activate a new language or Edit to change an existing supported language.

  3. If adding a new language, choose a language.

  4. To make the entered translations available to your users - select Active. Users can change their personal language anytime whether or not it's active in the Translation Workbench. Selecting Active makes the translations available to the users in that language.Tip: Don't make a language active until the translators have translated all values.

  5. To assign translators for this language, select them from the Available List and click Add. If you don’t see the member you want to add, enter keywords in

  6. Click Save

Then try this markup in your VF page:

 {!$ObjectType.Contact.fields.T_Role__c.Label}
Related Topic