跳到正文
Skillpedia
网站与界面(前端)75k · #2981

pluralization

它能做什么

这个技能检查网站如何显示“你有 3 个项目”之类的计数,并更新代码,让每种语言的复数形式都正确。它面向开发多语言应用的开发者。

适用场景

  • ✓你请智能体检查应用翻译中计数和复数如何书写的时候。
  • ✓译文读起来很奇怪,因为复数形式对该语言不正确的时候。
  • ✓你设置国际化库,并希望正确处理复数选择的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/pluralization/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/pluralization/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2981
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能