TABLE OF CONTENTS
Localization
Localization is the feature where your agents and users can view content on Freshchat in their preferred language. As part of Localization settings, the application takes care of text (Internationalization), dates, numbers and timestamps.
Freshchat messenger
The Freshchat messenger will be displayed based on the user’s browser language (also referred as locale)
Supported Locales
Freshchat messenger currently supports the following locales.
When the Freshchat Messenger is loaded for the first time, it automatically matches the user’s browser locale with the supported list and renders the content. For example, if the browser locale is Spanish, the header in the Freshchat messenger will be “Envíenos un mensaje” instead of “Message Us” on page load.
If the browser locale is not supported, the messenger will fallback to English.
Locale values based on countries are different. For example, the english language has locale values ‘en-us’ for American English and ‘en-gb’ for British English. The default English locale code for Freshchat is ‘en-us’. Even if the user’s browser locale is ‘en-gb’, the Freshchat Messenger will automatically map it to ‘en-us.’ This is the case for other locales too.
Note | Freshchat localization has Right-To-Left (RTL) support for Arabic and Hebrew languages |
Override Options
The Messenger locale can be overridden in the following ways.
1. Messenger Initialization
Set “locale” property in the window.fcWidget.init function as shown below.
<!--Body-->
<script>
function initFreshChat() {
window.fcWidget.init({
token: "WEB_CHAT_TOKEN", //Replace with your Freshchat Token by going to Admin > Web Messenger
host: "https://wchat.freshchat.com",
locale: "fr"
});
}
function initialize(i,t){var e;i.getElementById(t)?initFreshChat():((e=i.createElement("script")).id=t,e.async=!0,e.src="https://wchat.freshchat.com/js/widget.js",e.onload=initFreshChat,i.head.appendChild(e))}function initiateCall(){initialize(document,"freshchat-js-sdk")}window.addEventListener?window.addEventListener("load",initiateCall,!1):window.attachEvent("load",initiateCall,!1);
</script>
<!--Body-->
2. User update action
You can also set the language programmatically using the setLocale function.
window.fcWidget.user.setLocale(selectedLanguage)
Make sure selectedLanguage is one of the supported locales listed in the Supported locales table.
<!--Body-->
<script>
function initFreshChat() {
window.fcWidget.init({
token: "WEB_CHAT_TOKEN", //Replace with your Freshchat Token by going to Admin > Web Messenger
host: "https://wchat.freshchat.com"
//Widget initialized without locale
});
}
function initialize(i,t){var e;i.getElementById(t)?initFreshChat():((e=i.createElement("script")).id=t,e.async=!0,e.src="https://wchat.freshchat.com/js/widget.js",e.onload=initFreshChat,i.head.appendChild(e))}function initiateCall(){initialize(document,"freshchat-js-sdk")}window.addEventListener?window.addEventListener("load",initiateCall,!1):window.attachEvent("load",initiateCall,!1);
</script>
<script>
//Consider a dropdown with id #lang-btn to select the language
$('#lang-btn').on('change',function() {
var selectedLanguage = jQuery(this).val();
//Setting the Widget Locale
window.fcWidget.user.setLocale(selectedLanguage);//Replace selectedLanguage with preferred language such as ‘fr’
});
</script>
<!--Body-->
Note | If there is more than one browser locale enabled, Freshchat will always consider the default (primary) language. |