How to Set the Language for Multilingual Live Chat
If your chatbox needs to display a specific language, set its locale when initializing it. This guide explains how to add a locale parameter with the JavaScript SDK and how widget translations affect multilingual live chat.
txt.me chatbox supports multiple locales and shows its content depending on the language presets the visitor has in its browser. You can set up the translation on your widget’s settings page. Here we have a small manual on adding and editing language presets for the widgets.
Set up multilingual live chat when initializing a chatbox
Using JS SDK
When creating a new chatbox, it is possible to pass an array of parameters including visitor’s data.
Use the following code as an example. Replace the 00000000000000000000000000000000 with your widget’s id.
In the following example, we will set the ‘es’ locale, which is the code for Spanish(Español):
<script type="text/javascript">
window.txtmeData = {
params: {
locale: 'es'
},
};
(function (w,d,c,i) {
w[c]=w[c]||[];
var n = d.getElementsByTagName('script')[0],
s = d.createElement('script');
s.src = 'https://v2.txt.me/livechat/js/wrapper/' + i;
s.type = 'text/javascript';
s.async = true;
n.parentNode.insertBefore(s, n);
})(window,document,'txtmeData','00000000000000000000000000000000');
</script>
If you have the Spanish translation ready for your widgets, the chatbox will show all the texts in Spanish.