fix: Use account locale as the default locale on widget (#6248)

* fix: Use account locale as the default locale on widget

* Refactors check for invalid locale

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Nithin David Thomas
2023-01-16 12:14:35 +05:30
committed by GitHub
parent d488a42664
commit 70cb0a8ed9
2 changed files with 3 additions and 1 deletions

View File

@@ -18,7 +18,8 @@ const runSDK = ({ baseUrl, websiteToken }) => {
}
const chatwootSettings = window.chatwootSettings || {};
let locale = chatwootSettings.locale || 'en';
let locale = chatwootSettings.locale;
if (chatwootSettings.useBrowserLanguage) {
locale = window.navigator.language.replace('-', '_');
}

View File

@@ -135,6 +135,7 @@ export default {
});
},
setLocale(localeWithVariation) {
if (!localeWithVariation) return;
const { enabledLanguages } = window.chatwootWebChannel;
const localeWithoutVariation = localeWithVariation.split('_')[0];
const hasLocaleWithoutVariation = enabledLanguages.some(