2

Im trying to translate visualforce page. I have used custom labels to built the page. the page is translated good. For picklist values I used the below code, the picklist values are also translated based on the language (spanish in my case). But the problem is the picklist value is not saved as translated value. It stores in english.

<apex:selectRadio value="{!app.Program_Opinion__c}">
    <apex:selectOption itemValue="Yes" itemLabel="{!$Label.T001}"/>
    <apex:selectOption itemValue="No" itemLabel="{!$Label.T002}"/>                                            
</apex:selectRadio>

Example: For the above code. The English value of Program Opinion picklist field is Yes. The spanish translation is 'Si'. In the page it corectly displays as 'Si'. But it is stored as 'Yes. So, Now i changed the itemValue also as {!$Label.T001}. Below is the code.

<apex:selectRadio value="{!app.Program_Opinion__c}">
    <apex:selectOption itemValue="{!$Label.T001}" itemLabel="{!$Label.T001}"/>
    <apex:selectOption itemValue="{!$Label.T002}" itemLabel="{!$Label.T002}"/>                                            
</apex:selectRadio

The problem with this code now is rendering. I have outputpanel to render if the value is 'Yes'. Below is the rendering code. THis is not working. How to fix this? i cannot use 'Yes' directly in the rendered condition, because it will not be rendered if the value is translated to 'Si'

<apex:outputPanel rendered="{!app.Health_Indicated__c == '{!$Label.T001}' }" >                                  
<!-- code -->
</apex:outputPanel> 

Please let me know what did I miss.

Thanks

  • Using the translation workbench, the value of the picklist entries isn't translated, only the label. Though it doesn't appear that you're using translations of picklist values provided by the platform. Related question might help: salesforce.stackexchange.com/questions/37134 – Mark Pond Sep 1 '14 at 5:32
  • @BruceLee Print the value of the label and see what it prints .If you have kept value also in label ,this will imply value will also translate and you will be also comparing against translated value – Mohith Shrivastava Sep 1 '14 at 6:09
  • @BruceLee There is a spell error as well in the last part of code .May be that is the issue? – Mohith Shrivastava Sep 1 '14 at 6:12
  • @MohithShrivastava The value is printing as 'Si' as expected. Oh the spell error is here only. Sorry. That's not the error – sfdcFanBoy Sep 1 '14 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.