feat: 0 always uses 'zero' plural rule

This commit is contained in:
Lewis Crichton 2024-06-08 18:21:02 +01:00
parent 16549695d1
commit d349689c6a
No known key found for this signature in database

View file

@ -110,7 +110,8 @@ export function $t(key: string, variables?: Record<string, any>): string {
if (!variables || !variables.count) throw new Error(`translation key ${key} is an object (requires plurality?)`);
if (variables.count) {
const pluralTag = 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);