i18n 消息格式转换器
在 ICU MessageFormat、i18next、Vue I18n、Gettext PO 和 Intlayer 之间无缝转换翻译字符串和字典。实时测试动态变量。
加载示例预设
icu
ICU Plural with Exact Matchicu
ICU Select (Gender / Role)icu
ICU Selectordinal (Rankings)vue-i18n
Vue I18n Pipe Plurali18next
i18next Simple Interpolationicu
ICU Number & Percentage Formaticu
HTML / Rich Text Formattingicu
Full JSON Dictionary源格式formatjs / next-intl
79 字符
目标格式react-i18next
有效语法
交互式实时预览与计算
为检测到的变量设置测试值,以实时查看最终插值字符串。
语言区域:
渲染字符串预览 (en):
1 item in cart
消息格式对比与语法指南
直观了解所有支持格式之间的插值、复数、选择分支和数字格式语法对比。
| 功能 | ICU MessageFormat | i18next | Vue I18n | Intlayer |
|---|---|---|---|---|
简单变量 替换文本中的具名变量 | Hello {name}! | Hello {{name}}! | Hello {name}! | Hello {{name}}! |
CLDR 复数 基于语言类别的复数规则 (one, few, many, other) | {count, plural, one {# item} other {# items}} | {count, plural, one {# item} other {# items}} | 1 item | {count} items | plural({ one: '{{count}} item', other: '{{count}} items' }) |
精确匹配复数 显式映射具体数字(如 0、1) | {count, plural, =0 {No items} other {# items}} | {count, plural, =0 {No items} other {# items}} | No items | {count} items | enu({ '0': 'No items', fallback: '{{count}} items' }) |
Select / 性别选择 字符串条件匹配 | {gender, select, male {He} female {She} other {They}} | {gender, select, male {He} female {She} other {They}} | {gender: {male: "He", female: "She"}} | gender({ male: 'He', female: 'She', fallback: 'They' }) |
数字 / 百分比格式 本地化的数字格式样式 | {val, number, percent} | {{val, percent}} | $n(val, 'percent') | {val, number, percent} |
HTML / 富文本 保留用于排版的标记标签 | Read <strong>{doc}</strong> | Read <1>{{doc}}</1> | <i18n-t> or raw HTML | html('Read <strong>{{doc}}</strong>') |
类型安全编译
与变量拼写错误在运行时静默失败的传统系统不同,Intlayer 强制执行端到端 TypeScript 编译和 IDE 自动补全。
通用兼容层
无缝导入或导出来自 Next-intl、FormatJS、i18next 或 Nuxt 的消息,告别厂商锁定。
可视化 CMS 与 AI 翻译
在 Intlayer 中声明的内容可以在线实时可视化编辑,或通过内置的 AI 流水线自动翻译到 18+ 种语言。
Intlayer 生态系统
迁移至 Intlayer,享受完整的类型安全
在代码旁就近声明翻译,在构建时捕获缺失的键,并配合可视化 CMS 进行内容编辑。