From d349689c6a5fe64e1d55a9eb945b45a0213809d1 Mon Sep 17 00:00:00 2001 From: Lewis Crichton Date: Sat, 8 Jun 2024 18:21:02 +0100 Subject: [PATCH] feat: 0 always uses 'zero' plural rule --- src/utils/translation.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/translation.tsx b/src/utils/translation.tsx index a1cba453d..14ea8657f 100644 --- a/src/utils/translation.tsx +++ b/src/utils/translation.tsx @@ -110,7 +110,8 @@ export function $t(key: string, variables?: Record): 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);