Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadLocales() {
let currentLocale = intl.determineLocale({
urlLocaleKey: "lang",
cookieLocaleKey: "lang"
});
if (!_.find(SUPPOER_LOCALES, { value: currentLocale })) {
currentLocale = "en-US";
}
http
.get(`locales/${currentLocale}.json`)
.then(res => {
console.log("App locale data", res.data);
// init method will load CLDR locale data according to currentLocale
return intl.init({
currentLocale,
locales: {
[currentLocale]: res.data
function loadLocales() {
let targetLocale = intl.determineLocale({ cookieLocaleKey: COOKIE_KEYS.LANG }) as LOCALES_KEYS
// default is English
if (!find(SUPPOER_LOCALES, { value: targetLocale })) {
targetLocale = LOCALES_KEYS.EN_US
}
getLocaleLoader(targetLocale).then(res => {
intl.init({ currentLocale: targetLocale, locales: { [targetLocale]: res.localeData } }).then(() => {
setCurrentLocale(targetLocale)
setAntdLocaleData(res.antdLocaleData)
})
})
}