+ Start a Discussion
swasswas 

Multi language pages using visualforce

I had 2 languages with links "en" and "french" . Using custom labels i had created custom label with 2 languages. when i click french the words in visual force  page must change into french language and when i click on "En" the same french text must change into English. 
how can i achieve??
Sforce.NinjaSforce.Ninja
You need to use the Language attribute on the apex:Page tab
 
<apex:page language="{!$CurrentPage.parameters.lang}">

replace the Lang parameter with whatever you are using to send the language.

If you find this answer useful, please mark this as best answer!!
Cheers,
Sid,
Sforce.Ninja
 
mjohnson-TICmjohnson-TIC
You will need to translate the page and split it into different sections for English and French. Then create a variable to determine which language it is displaying and create onclick action methods to rerender the page depending on which label you click.

Something like this.

Visualforce page
<apex:page id="thepage" controller="PageController">
	<apex:form id="theform">
		<apex:commandlink action="{!changeEnglish}" rerender="theform" value="English"/>
		<apex:commandlink action="{!changeFrench}" rerender="theform" value="French"/>
		<apex:outputpanel rendered="{!!isFrench}">
		English words
		</apex:outputpanel>
		<apex:outputpanel rendered="{!isFrench}">
		mots français
		</apex:outputpanel>		
	</apex:form>
</apex:page>

Apex Class
 
public with sharing class PageController {
public boolean isFrench {get;set;}

public void changeFrench(){
	isFrench = true;
}

public void changeEnglish(){
	isFrench = false;
}

}

 
mjohnson-TICmjohnson-TIC
Never knew the language tag existed Sforce.Ninja, nice to know!
Sforce.NinjaSforce.Ninja
If it helps please mark it as best answer.
Cheerts.
swasswas
Hi sforce

can i use same in case of custom labels?? 
swasswas
I had used this tag:

 <apex:outputLabel value="{!$Label.test}" rendered="true"/>

but i am not getting translation??
mjohnson-TICmjohnson-TIC
This should work if you want Salesforce to do the translation for you.

Visualforce Page
 
<apex:page id="thepage" controller="PageController" language="{!IF(ISNULL(language),'en_US',language)}">
	<apex:form id="theform">
		<apex:actionfunction name="changeEnglish" action="{!changeEnglish}" rerender="thepage"/>
		<apex:actionfunction name="changeFrench" action="{!changeFrench}" rerender="thepage"/>
		<apex:outputLabel value="{!$Label.french}" rendered="true" onclick="changeEnglish();"/>
		<apex:outputLabel value="{!$Label.english}" rendered="true" onclick="changeFrench();"/>
		Text of page here
	</apex:form>
</apex:page>

Apex Class
 
public with sharing class PageController {
public string language {get;set;}

public void changeFrench(){
	language = "fr";
}

public void changeEnglish(){
	language = "en_US";
}

}

 
swasswas
Hi mjohnson-TIC,

I had only 1 thing left.

i need 2 keep 2 links which you specified like 1st one.
 
<apex:page id="thepage" controller="PageController1" language="{!IF(ISNULL(language),'en_US',language)}">
    <apex:form id="theform">
            <apex:commandlink action="{!changeEnglish}" rerender="thepage" value="English"/><br/>
<br/><br/>
        <apex:commandlink action="{!changeFrench}" rerender="thepage" value="French"/><br/><br/><br/>

    
       
        <apex:outputLabel value="{!$Label.french}" rendered="true" onclick="changeEnglish();"/><br/>
        <apex:outputLabel value="{!$Label.english}" rendered="true" onclick="changeFrench();"/><br/><br/><br/><br/>
        Text of page here
    </apex:form>
</apex:page>
 
public with sharing class PageController1 {
public string language {get;set;}
public boolean isFrench {get;set;}

public void changeFrench(){
    language = 'fr';
     isFrench = true;
}

public void changeEnglish(){
    language = 'en_US';
        isFrench = false;

}

}

but i am not getting correct output. I just need to get english by default an if i click on "french" words must change to french 
sai chandu 10sai chandu 10
I am not geeting correct out put please  can any one expliain to me
sai chandu 10sai chandu 10
I had 2 languages with links "en" and "french" . Using custom labels i had created custom label with 2 languages. when i click french the words in visual force  page must change into french language and when i click on "En" the same french text must change into English. 
how can i achieve??
sai chandu 10sai chandu 10
CAN ANYONE PLEASE WRITE THE CODE
Create 20 records for the above object and write a batch which fetch all the details where PO Status is equal to Shipped and send an email to those customers where the email is not blank, in case if you didn’t found an email in Customer Email field check in related account email(create an email field in Account object) and send an email?