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
PrappPrapp 

Translation problem of custom label with Apex class and visualforce page

Hi All,

 

I got a problem about custom label translation if I am specified the language in visualForce page different from the current user’s language. I created the visualforce page with specified language and then I get the value of Radio button’s option from class, but the label of radio button is translated to be user’s language instead of visualforce page’s languaged. Example: if my user's language is 'Chinese' and I set my visual force page language is 'Japanese' then the label of my radio button is 'Chinese', but other label fields in visual force page are translated to 'Japanese'. My code is as following.

 

visualforce page

<apex:page controller="testCon" language="ja" sidebar="false" showheader="false">
 <apex:form >
    <apex:panelGrid columns="1" width="600px" style="text-align:center">
       <apex:pageBlock >
       <apex:pageBlockSection columns="1" >
          <apex:pageBlockSectionItem >
             <apex:outputText value="{!$Label.Gender}"/>
             <apex:selectRadio value="{!Gender}">
                <apex:selectOptions value="{!pGenders}" />  
             </apex:selectRadio>
           </apex:pageBlockSectionItem>
       </apex:pageBlockSection>
       </apex:pageBlock>
    <apex:panelGrid>
   </apex:form>
</apex>

 

class controller

 

public class testCon {
   String Gender = 'Male';
  
   public List<SelectOption> getpGenders() {
      List<SelectOption> options = new List<SelectOption>();
      options.add(new SelectOption('Male',System.Label.Male));
      options.add(new SelectOption('Female',System.Label.Female));
      return options;
   }
  
   public String getGender() {
      return Gender;
   }
 
   public void setGender(String Gender) {
      this.Gender = Gender;
   }
 
}

 

 

Anyone can be suggest me?

 

Thanks you,

Prapp

paul-lmipaul-lmi
known limitation with no graceful workaround.  we had to pass the visualforce translated values back into the controller to get it done properly.
PrappPrapp
Could you please give me an example or more detail?
paul-lmipaul-lmi
we had the messages directly in the VF page, and then used an actionfunction to map them back to a controller variable.  it's very messy, and it didn't work well, so i'm not inclined to include sample code.  i think there's an idea on the ideaexchange you can vote up to get this properly supported.
PrappPrapp

Ok. Thanks you for your reply.