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:
committed by
GitHub
parent
d488a42664
commit
70cb0a8ed9
@@ -18,7 +18,8 @@ const runSDK = ({ baseUrl, websiteToken }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const chatwootSettings = window.chatwootSettings || {};
|
const chatwootSettings = window.chatwootSettings || {};
|
||||||
let locale = chatwootSettings.locale || 'en';
|
let locale = chatwootSettings.locale;
|
||||||
|
|
||||||
if (chatwootSettings.useBrowserLanguage) {
|
if (chatwootSettings.useBrowserLanguage) {
|
||||||
locale = window.navigator.language.replace('-', '_');
|
locale = window.navigator.language.replace('-', '_');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
setLocale(localeWithVariation) {
|
setLocale(localeWithVariation) {
|
||||||
|
if (!localeWithVariation) return;
|
||||||
const { enabledLanguages } = window.chatwootWebChannel;
|
const { enabledLanguages } = window.chatwootWebChannel;
|
||||||
const localeWithoutVariation = localeWithVariation.split('_')[0];
|
const localeWithoutVariation = localeWithVariation.split('_')[0];
|
||||||
const hasLocaleWithoutVariation = enabledLanguages.some(
|
const hasLocaleWithoutVariation = enabledLanguages.some(
|
||||||
|
|||||||
Reference in New Issue
Block a user