Replies: 0
How to set the chatbox Multilanguage
i have 3 language site ‘fr’, ‘de’, ‘en’
here my script please check and suggest
window.$crisp=[];CRISP_RUNTIME_CONFIG ={locale : 'fr'};window.CRISP_WEBSITE_ID="xxxx7666";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();
And below your plugin code
function crisp_hook_head() {
$website_id = get_option('website_id');
$locale = str_replace("_", "-", strtolower(get_locale()));
if (!in_array($locale, array("pt-br", "pt-pr"))) {
$locale = substr($locale, 0, 2);
}
if (!isset($website_id) || empty($website_id)) {
return;
}
$output="<script data-cfasync='false'>
window.\$crisp=[];
CRISP_RUNTIME_CONFIG = {
locale : '$locale'
};
CRISP_WEBSITE_ID = '$website_id';";
$output .= "(function(){
d=document;s=d.createElement('script');
s.src='https://client.crisp.chat/l.js';
s.async=1;d.getElementsByTagName('head')[0].appendChild(s);
})();";
$output .= crisp_sync_wordpress_user();
$output .= crisp_sync_woocommerce_customer();
$output .= "</script>";
echo $output;