1

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?

1

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}
0

Solved by using the outputField tag

<apex:outputField value="fieldName"/>

And specifying the language in the apex component

<apex:component access="global" language="fr" controller="..." >
  • 1
    Please specify how this met your needs. Were you able to specify which language to use in the output value? – Charles T Jan 12 '18 at 15:38

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.