August 26, 2021

Dynamically Change Language for Salesforce Embedded Service Chat

Apex Class:
public class EmbeddedChatController {

    public String selectedOption { get; set; }
    
    public EmbeddedChatController() {
    
        selectedOption = ApexPages.currentPage().getParameters().containsKey( 'language' ) ? ApexPages.currentPage().getParameters().get( 'language' ) : 'da';
        
    }
    
    public PageReference changeLanguage() {
    
        system.debug( 'Changed Language is ' + selectedOption );
        PageReference pg = new PageReference( '/apex/EmbeddedChat' );
        pg.getParameters().put( 'language', selectedOption );
        pg.setRedirect(true);
        return pg;
    
    }

}

Visualforce Page:


Output:


No comments:

Post a Comment