7

We are using

<apex:pageBlock title="{account.MyField__c}">

where MyField is a picklist with the corresponding translations. The problem is that the picklist value is not translated to the user's language. From here I found that including raw picklist fields in VF doesn't get translated and that we should use apex:outputField. But I can't find a way of using it inside the pageBlock title attribute.

Any ideas on how to get the translation inside the title?

5
  • Based on that doc, you won't be able to do it per se; probably the "easiest" workaround is to render a hidden outputField and then use JS/jQuery magic to stuff into the page block title.
    – jkraybill
    May 6, 2013 at 13:49
  • 2
    Based on the issue you linked this has been fixed. I'd suggest contacting SFDC support and letting them know you're still experiencing the issue May 6, 2013 at 14:51
  • Unfortunately, the Known Issues page is incorrect. The issue has not been fixed. I've brought it to the attention of the page owner. May 8, 2013 at 2:07
  • @Carolyn, could you please post your comment as the answer to the question unless you have updated information?
    – crmprogdev
    May 10, 2013 at 13:14
  • @crmprogdev I don't have any update, other than that the Known Issues page has been corrected now. I actually think jkraybill's response is a more likely answer, though I haven't tried it to see. May 10, 2013 at 23:15

1 Answer 1

2

This might do the trick:

Schema.DescribeFieldResult F = Account.MyField__c.getDescribe(); 
List<Schema.PicklistEntry> P = F.getPicklistValues(); 
Map<String, String> mapMyFieldTranslation = new Map<String, String>(); 

for(Schema.PicklistEntry e : P){
    mapMyFieldTranslation.put(e.value, e.label); 
}

String result = mapMyFieldTranslation.get(myAccount.MyField__c));

With 'result' containing the translation.

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.