function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
moniferlomoniferlo 

Localized Visualforce page using merge fields for picklist

My org has translation workbench enabled and all the labels, picklist values and messages are translated to different languages. I would like to develop a Visualforce page that shows data collected from several objects in the user's language. Most of the information can be reached using merge fields without programming a controller extension, but merge fields that reference picklist values show  the master value, not the label in the user's language, is there any way to translate the picklist value using merge fields, something like "tolabel"? If not, I presume that I will have to develop a controller extension and use Describe functions, or is there any other easier way?
etoeto

We experience the same problem.

 

Does anyone have a solution to this?

 

Moreover, is it possible to select the language at runtime (e.g. the user has a german interface but wants to print an english contract document using pdf-rendering)?

 

regards

 

PerGeertPerGeert
I haven't yet figured out what to do with picklists. However, your second question can solved by adding language={!Language} in the page tag and in your controller set the language to whaever, e.g. 'ge', depending on whatever criteria.
PerGeertPerGeert

In apex:page tag use language="{!Language}"

In controller set Language, e.g. to 'de'

In page use apex:outputfield value="{!somepicklistfield}"

 

Thats does the trick for me. Also, dates and currencies are (more) properly formated using outputfield.

PGNPGN

We are trying to solve a similar problem. How did you set the language in the controller ?

 

 

PerGeertPerGeert

Hm, interesting - my initials are also PGN.

Anyhow, I my case the user selects a language, since it does not necessarily depends on the user's language. The value is stored in the object Offer, so in the controller:

 

  public string getLanguage() {
    if (offer == null) getOffer();
    if (offer.Language__c == 'German') return 'de';
    if (offer.Language__c == 'Spanish') return 'es';
    if (offer.Language__c == 'Portuguese') return'pt';
    if (offer.Language__c == 'Russian') return 'ru';
    return 'en';
  } 

 

Best regards,

Per