currency-formatting
它能做什么
这项技能检查网站如何向不同国家的人显示金额、数字和日期。适合构建服务于多个地区网站的开发者。
适用场景
- ✓当你的价格对某个国家显示了错误的货币符号或分隔符时。
- ✓当日期的格式让海外用户感到困惑时。
- ✓当你为网站添加新的语言或地区时。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/currency-formatting/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“你能检查一下我网站上的价格对其他国家的访客是否显示正确吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会查找数字、价格或日期被手动输入的地方,并建议使用浏览器内置的格式化工具,并以访客的语言进行格式化。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use Intl APIs for currency, number, and date formatting
Number and currency formatting rules differ significantly across locales — a value formatted as "$1,234.56" in the US is written "1.234,56 $" in Germany and "¥1,235" in Japan. Hardcoded formatting causes incorrect display for international users and is expensive to maintain manually as you add locales.
Quick Reference
- Never hardcode currency symbols or thousand separators like $ or comma
- Use Intl.NumberFormat with the currency style for monetary values
- Use Intl.DateTimeFormat for locale-aware date and time display
- Pass the user locale explicitly rather than relying on the browser default
- Use Intl.Collator and locale fallback chains for sorting and searching
Check
Identify all places in this codebase where numbers, currencies, or dates are formatted manually instead of using Intl.NumberFormat or Intl.DateTimeFormat. Also flag locale-sensitive sorting that uses plain string comparison instead of Intl.Collator and any formatter that lacks a fallback locale.
Fix
Replace manual number and currency formatting with Intl.NumberFormat and replace manual date formatting with Intl.DateTimeFormat, passing the user locale explicitly. Use Intl.Collator for locale-aware sorting and resolve a supported fallback locale when the requested locale is unavailable.
Explain
Explain why locale-aware formatting with Intl APIs is required for international applications, what goes wrong when formatting is hardcoded, and why sorting/searching should also use locale-aware comparison.
Code Review
Review utility functions and components that render numbers, prices, percentages, or dates. Flag any hardcoded currency symbols, separators, or date format strings, and show Intl-based alternatives.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/i18n/currency-formatting
常见问题
为什么价格在其他国家看起来不同?
各国使用不同的货币符号、小数点符号和分隔符,同样的金额可能写法大不相同。
它使用哪些浏览器工具?
这项技能建议使用现代浏览器内置的 Intl 格式化工具,用于数字、货币、日期和排序。
语言应该在代码中设置吗?
这项技能建议明确传入用户的 locale,而不是依赖浏览器的默认值。
详情
作者的原始描述
Use when reviewing utility functions, component props, or template strings that format numbers, prices, or dates to check whether Intl APIs are used correctly.
热度
- GitHub 星标
- 75k
- 排名
- #2805
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。