There are 2 picklist fields in my VF page. I successfully translated the whole VF page using custom labels (into Spanish), but the picklist values are not translated. How to translate them?

Here's the VF code of the picklist fields.

<div class="form-label left "><apex:outputLabel value="{!$Label.T97}" /></div>
<div class="form-field">    
    <apex:inputField id="Program_Duration" value="{!app.Program_Duration__c}" required="true"/>

<div class="form-label left "><apex:outputLabel value="{!$Label.T95}" /></div>                                
    <apex:selectRadio value="{!app.Program_Opinion__c}" id="start-opinion" required="TRUE">
        <apex:selectOption itemValue="1 Week" itemLabel="1 Week"/>
        <apex:selectOption itemValue="2 Weeks" itemLabel="2 Weeks"/>                                            

I dont want to use {!label.1Week} and {!label.2Weeks} in the 'itemLabel' for for the Program_opinion__c picklist field (2nd picklist) as there are more than 30 weeks. I don't want to create so many custom labels.

Please suggest the solution.

  • 2
    You have to. The labels are there for it. In my org for example we have over 2000 labels in a big project. Or translate your picklist values in translation workbench and use inputField or outputField on the visualforce page. – Sergej Utko Aug 21 '14 at 7:58
  • @mast0r that's worthy of an answer – Samuel De Rycke Aug 21 '14 at 8:27

You have to use labels or translation workbench.

There are some options to display translated picklists on the visualforce.

  1. A salesforce standard way to is to use apex:inputField tag with assigned sobject field of type picklist. In this case a picklist will be generated automatically with respect to the current user language. All you need to do is translate each picklist value with translation workbench

    enter image description here

  2. The second option is to create a picklist on the visualforce page with apex:selectList tag and use labels for each apex:selectOption entry (like in your example). That's not bad at all to use labels, even if you need to create a tons of it. It is absolute ok to have several hundreds or even thousands of label, depends on the project size.

| improve this answer | |
  • Thanks for the explanation. So, for the first picklist values, I can use the Translation workbench --> Translate option to translate because Im using <apex:inputField> anyways, so I dont need to change the code for this. And for the 2nd picklist as you said I will create custom labels for each picklist value. Let me know if Im wrong. thanks much – sfdcFanBoy Aug 21 '14 at 9:32
  • @BruceLee You are right :) – Sergej Utko Aug 21 '14 at 10:11
  • I have a problem with this. I created labels and used them in itemLabel for picklist label. itemLabel="{!$Label.T001}". It is translated good. But the value stored is NOT translated after save. Also this rendered condition is not working. rendered="{!app.Health_Indicated__c == '{!$Labe.T001}' }" – sfdcFanBoy Sep 1 '14 at 4:42
  • I created a new detailed question for this. Pleas help. This is the link. Thanks salesforce.stackexchange.com/questions/48218/… – sfdcFanBoy Sep 1 '14 at 5:03

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.