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

currency-formatting

它能做什么

这项技能检查网站如何向不同国家的人显示金额、数字和日期。适合构建服务于多个地区网站的开发者。

适用场景

  • ✓当你的价格对某个国家显示了错误的货币符号或分隔符时。
  • ✓当日期的格式让海外用户感到困惑时。
  • ✓当你为网站添加新的语言或地区时。

技能链接

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

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

使用方法

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

可直接粘贴的消息

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

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

repo: thedaviddias/Front-End-Checklist

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能