How do I change the language of CometChat on load?

If you have a multi-lingual website, you may want to change the default language of CometChat before loading it.

  1. Make sure that the language pack has been added in CometChat Admin Panel -> Localization.
  2. Set the language using a simple cookie before adding the CometChat HTML code. For example, if you want to set the language to French, your code will be something like-
// Set Expiry Date
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();

// Set Cookie
document.cookie = 'cc_lang' + "=" + 'fr' + expires + "; path=/";

You can learn more about it in our developer documentation.