1

I'm currently working on a Live Agent Chat implementation and need your help. The requirements warrant a custom chat window, and we'll also need to localize the custom chat window in different languages. I have replaced the messages (ex: the waiting message) with custom labels. For the visualforce markup, I have:

<apex:page showheader="false" standardstylesheets="false" language="?">

However, I don't know how to set the language attribute dynamically from the pre-chat form.

Does anyone know how to set the language dynamically for custom chat windows using visualforce?

It looks like the chat endpoint generated by the pre-chat form already has a language parameter, which is just set to #. I imagine we can probably just parse out the endpoint and set the language there, but I'm hoping there's an easier way.

I've also assigned the chat buttons to the appropriate language in setup, but that doesn't seem to do anything for custom chat windows. I've had no luck with premier support and cannot find documentation on setting the language for custom chat windows. Please help!

Thanks!

1

2 Answers 2

2

You could create a controller for your chat window and do something like this:

public with sharing class mychatcontroller{

          public string getChatLanguage()
          {               
                string chatURL=EncodingUtil.urlDecode(ApexPages.currentPage().getUrl(),'UTF-8');
                return chatURL.substringBetween('language=','#');
          }

}

And then on your page

<apex:page showheader="false" controller="mychatcontroller" standardstylesheets="false" language="{!ChatLanguage}">
0

Ok. I'm talking to myself, but this quick and dirty hack on the endpoint worked:

        <script type="text/javascript">
         (function() { 
         function handlePageLoad() {
           var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
           var endpoint = endpointMatcher.exec(document.location.search)[1];           
           document.getElementById('prechatForm').setAttribute('action',
               decodeURIComponent(endpoint).replace('language=','language='+yourLanguageParameter));
         } if (window.addEventListener) {
                  window.addEventListener('load', handlePageLoad, false);
       } else { window.attachEvent('onload', handlePageLoad, false);
                  }})(); 
     </script>

Simply set the language using your own language parameter by using a replace. The # must also be preserved in your endpoint in order for chat to work.

If anyone else has a less hackish way to accomplish this, please do let me know!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .