Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const updateLocale = function (locale) {
// blow away the cache to force it to reload the manifest files for the new app
// eslint-disable-next-line no-undefined
if (ilib._load) ilib._load.manifest = undefined;
// remove the cache of the platform name to allow transition between snapshot and browser
delete ilib._platform;
// load any external ilib/resbundle data
ilib.data = global.ilibData || ilib.data;
ilib.data.cache = ilib.data.cache || {};
ilib.data.cache['ResBundle-strings'] = global.resBundleData || {};
// ilib handles falsy values and automatically uses local locale when encountered which
// is expected and desired
ilib.setLocale(locale);
const newLocale = ilib.getLocale();
// Recreate the case mappers to use the just-recently-set locale
initCaseMappers();
return newLocale;
};
function createResBundle (options) {
let opts = options;
if (typeof ILIB_MOONSTONE_PATH !== 'undefined') {
opts = {
loadParams: {
root: ILIB_MOONSTONE_PATH
},
...options
};
}
if (!opts.onLoad) return;
// Swap out app cache for moonstone's
const appCache = ilib.data;
ilib.data = global.moonstoneILibCache || cache;
// eslint-disable-next-line no-new
new ResBundle({
...opts,
onLoad: (bundle) => {
ilib.data = appCache;
opts.onLoad(bundle || null);
}
});
}
const updateLocale = function (locale) {
// blow away the cache to force it to reload the manifest files for the new app
// eslint-disable-next-line no-undefined
if (ilib._load) ilib._load.manifest = undefined;
// remove the cache of the platform name to allow transition between snapshot and browser
delete ilib._platform;
// load any external ilib/resbundle data
ilib.data = global.ilibData || ilib.data;
ilib.data.cache = ilib.data.cache || {};
ilib.data.cache['ResBundle-strings'] = global.resBundleData || {};
// ilib handles falsy values and automatically uses local locale when encountered which
// is expected and desired
ilib.setLocale(locale);
const newLocale = ilib.getLocale();
// Recreate the case mappers to use the just-recently-set locale
initCaseMappers();
return newLocale;
};
const updateLocale = function (locale) {
// blow away the cache to force it to reload the manifest files for the new app
// eslint-disable-next-line no-undefined
if (ilib._load) ilib._load.manifest = undefined;
// remove the cache of the platform name to allow transition between snapshot and browser
delete ilib._platform;
// load any external ilib/resbundle data
ilib.data = global.ilibData || ilib.data;
ilib.data.cache = ilib.data.cache || {};
ilib.data.cache['ResBundle-strings'] = global.resBundleData || {};
// ilib handles falsy values and automatically uses local locale when encountered which
// is expected and desired
ilib.setLocale(locale);
const newLocale = ilib.getLocale();
// Recreate the case mappers to use the just-recently-set locale
initCaseMappers();
return newLocale;
};
let opts = options;
if (typeof ILIB_MOONSTONE_PATH !== 'undefined') {
opts = {
loadParams: {
root: ILIB_MOONSTONE_PATH
},
...options
};
}
if (!opts.onLoad) return;
// Swap out app cache for moonstone's
const appCache = ilib.data;
ilib.data = global.moonstoneILibCache || cache;
// eslint-disable-next-line no-new
new ResBundle({
...opts,
onLoad: (bundle) => {
ilib.data = appCache;
opts.onLoad(bundle || null);
}
});
}