ITADN

count() function typings don't accept all of the Intl.PluralRules forms

#40OpenlunarW1TCH 创建于 2025-06-25
L
lunarW1TCHcommented
Typing of values in count method specifies only 3 hardcoded values. ```typescript // @nanostores/i18n/count/index.d.ts export type CountInput = { few?: TranslationJSON many: TranslationJSON one?: TranslationJSON } ``` Additionally all rules other than those 3 are changed to "many": ```typescript // @nanostores/i18n/count/index.js export const count = transform((locale, translation, num) => { let form = new Intl.PluralRules(locale).select(num) if (!(form in translation)) form = 'many' return strings(translation[form], str => str.replace(/{count}/g, num)) }) ``` This is a problem for languages like polish which also have an "other" rule that is distinct from "many".
3 条评论