Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getI18nClasses (options = {}) {
const {sync, onLoad} = options;
if (!onLoad) return;
// eslint-disable-next-line no-new,no-undefined
new LocaleInfo(undefined, {
sync,
onLoad: (li) => getClassesForLocale(li, {
...options,
onLoad
})
}); // for the current locale
}
function isNonLatinLocale (spec, options = {}) {
const {onLoad, latinLanguageOverrides, nonLatinLanguageOverrides, ...rest} = options;
if (!onLoad) return;
// eslint-disable-next-line no-new
new LocaleInfo(spec, {
...rest,
onLoad: (li) => {
const locale = li.getLocale();
onLoad(
// the language actually is non-latin and should not be treated as latin
(li.getScript() !== 'Latn' && !includesLocale(latinLanguageOverrides, locale)) ||
// the language is latin but should be treated as non-latin
includesLocale(nonLatinLanguageOverrides, locale)
);
}
});
}
length: 'full',
date: 'dmwy'
});
// Meridiem localization
const merFormatter = new DateFmt({
template: 'a',
useNative: false,
timezone: 'local'
});
const meridiems = merFormatter.getMeridiemsRange();
const meridiemRanges = meridiems.map(calcMeridiemRange);
const meridiemLabels = meridiems.map(obj => obj.name);
// Picker ordering
const li = new LocaleInfo();
const clockPref = li.getClock();
const meridiemEnabled = clockPref === '12';
const filter = meridiemEnabled ? includeMeridiem : excludeMeridiem;
const order = formatter.getTemplate()
.replace(/'.*?'/g, '')
.match(filter)
.map(s => s[0].toLowerCase());
return {
formatter,
meridiemEnabled,
meridiemLabels,
meridiemRanges,
order
};