chore: remove unnecessary if

This commit is contained in:
Lewis Crichton 2024-06-24 19:00:26 +01:00
parent e55c6f99e2
commit faea1c8224
No known key found for this signature in database

View file

@ -108,17 +108,15 @@ export function t(key: string, variables?: Record<string, any>): string {
if (!variables || !variables.count)
throw new Error(`translation key ${key} is an object (is it a plural?)`);
if (variables.count) {
const pluralTag: Intl.LDMLPluralRule = variables.count === 0 ? "zero" :
new Intl.PluralRules(bestLocale).select(variables.count);
const pluralTag: Intl.LDMLPluralRule = variables.count === 0 ? "zero" :
new Intl.PluralRules(bestLocale).select(variables.count);
if (translation[pluralTag]) {
return format(translation[pluralTag]!, variables);
} else if (translation.other) {
return format(translation.other, variables);
} else {
throw new Error(`translation key ${key} is an object and doesn't seem to be plural`);
}
if (translation[pluralTag]) {
return format(translation[pluralTag]!, variables);
} else if (translation.other) {
return format(translation.other, variables);
} else {
throw new Error(`translation key ${key} is an object and doesn't seem to be plural`);
}
}