Hello,
I have tried both methods and could make them work.
App.setLanguage
You can invoke the "App.setLanguage" command to change the language after the widgets is initialized/loaded.
The new labels will appear the next time the WebChat window (Registration form, ...) is opened.
I mean that if you can the "App.setLanguage" command while the WebChat Registration form is already opened, it will not dynamically change all labels to the new language.
If you close and reopen the chat window, the new labels will be there.
So it is better to invoke that command before opening the WebChat window (i.e. before "WebChat.open").
The thing to pay attention to is that the window._genesys.widgets.main.i18n must be configured/initialized with all the languages you plan to use.
English language is "included" in the WebChat libraries.
For other languages, you have to point to a file containing the label translations or set the translations directly in the i18n property.
https://all.docs.genesys.com/WID/Current/Developer/GWCInternat
In my test, I had set my widgets to english by default.
And loaded a file for french (english being already built into the widgets library).
In my widgets configuration:
window._genesys.widgets.main.lang = 'en';
window._genesys.widgets.main.i18n = 'https://apps.mypurecloud.com/widgets/9.0/i18n/widgets-fr.i18n.json';
If you want more than 2 languages, you would have to take the translations for the different languages, copy them into a single json file and point to this file via the i18n property.
Then, after loading/initializing the widgets, and before opening the chat, I have invoked:
CXBus.command('App.setLanguage', {lang: 'fr'});
Then, when I open/start my chat, labels are in french.
Common.updateTemplateI18n
This one is to be used at runtime, while the WebChat window is already opened.
I did a test and the container apparently needs to be a div (I I have tried a reference to the button directly and it didn't update the text).
Assuming you have jquery lib loaded/available in your page, and that the WebChat Registration form is currently displayed.:
I first retrieve a reference to the div containing the StartChat and Cancel buttons (it is necessary to add cx-form class in the jquery selector as there are different buttons/divs with .cx-button-group.cx-buttons-binary - ex: the close chat icon/button).
var myContainer = $(".cx-form .cx-button-group.cx-buttons-binary");
var Common = _genesys.widgets.common;
Common.updateTemplateI18n(myContainer, {ChatFormCancel: 'Annulation', ChatFormSubmit: 'Démarrer'});
Regards,