pluralization
它能做什么
这个技能检查网站如何显示“你有 3 个项目”之类的计数,并更新代码,让每种语言的复数形式都正确。它面向开发多语言应用的开发者。
适用场景
- ✓你请智能体检查应用翻译中计数和复数如何书写的时候。
- ✓译文读起来很奇怪,因为复数形式对该语言不正确的时候。
- ✓你设置国际化库,并希望正确处理复数选择的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/pluralization/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的应用在某些语言中会显示“1 个项目”这类计数,但复数形式出错了。请帮我修复所有语言的复数处理方式吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会找出把计数与文字用加号拼接,或只判断单数和复数的地方。它会用 Intl.PluralRules 或 ICU 消息语法替换,使每种语言都选中正确的形式。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Handle plural forms with Intl.PluralRules or ICU MessageFormat
Pluralization rules vary dramatically across languages — what works as a simple singular/plural branch in English produces grammatically wrong output in Arabic, Russian, Polish, and dozens of other languages. Shipping incorrect plurals signals low translation quality and breaks trust with native speakers in target markets.
Quick Reference
- English has 2 plural forms but Arabic has 6 and Russian has 3
- Never concatenate a count with a string like '"You have " + count + " items"'
- Use Intl.PluralRules to select the right message key per locale
- ICU MessageFormat in react-intl or i18next handles plural selection automatically
Check
Find all places in this codebase where a count value is concatenated with a string or where only singular/plural branching is used, without Intl.PluralRules or ICU plural syntax.
Fix
Replace count string concatenation and binary singular/plural logic with Intl.PluralRules-based key selection or ICU MessageFormat plural syntax so that all CLDR plural categories are covered for every target locale.
Explain
Explain why languages have different numbers of plural forms, what CLDR plural categories are, and how Intl.PluralRules and ICU MessageFormat solve pluralization correctly across locales.
Code Review
Review translation files and components that render counts. Flag any strings that concatenate a number with text, any ternary that picks only between "singular" and "plural", and any i18next or react-intl message that is missing plural keys required by the target locale.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/i18n/pluralization
常见问题
为什么只有单数和复数两种形式不够?
这个技能说,不同语言差异很大:英语有两种复数形式,阿拉伯语有六种,俄语有三种。
什么是 Intl.PluralRules?
它是浏览器内置的功能,能为给定语言中的数字选出正确的复数类别。
这适用于常用的库吗?
这个技能提到 react-intl 和 i18next 等库中的 ICU MessageFormat,它们负责复数选择。
详情
作者的原始描述
Use when reviewing string concatenation involving counts, translation key lookups, or i18n library configurations to check whether plural forms are handled correctly for all target locales.
热度
- GitHub 星标
- 75k
- 排名
- #2981
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。