Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getPluralRuleFunctionCode(locale) {
if (plurals.hasOwnProperty(locale)) {
const expectedLocale = getPluralRulesLocale(locale)
if (locale !== expectedLocale) {
throw new Error(`Expected to find pluralization rules for "${expectedLocale}" locale but found them for "${locale}" locale`)
}
return {
locale,
quantify: new MakePlurals(locale).toString('classify')
}
}
const parts = locale.split('-')
parts.pop()
locale = parts.join('-')
if (locale) {
return getPluralRuleFunctionCode(locale)
}
// Not found.