ICU 消息格式化与编辑器
使用实时预览、100+ 模板和多语言 CLDR 复数验证来构建、测试和验证 ICU MessageFormat 字符串。
模板50
ICU 编辑器
语法有效
14 字符1 行
测试变量与实时预览
调整变量并切换语言以验证 CLDR 复数规则
语言环境:
渲染输出 (en):
Hello, Alex!
导出为 Intlayer 类型安全声明
Intlayer 在编译时通过完整的 TypeScript 自动补全来验证翻译。
ICU MessageFormat Syntax Cheat Sheet
快速语法规则以及每个模式如何映射到 Intlayer 的类型安全声明
| 功能 | 语法 | 示例 | 备注 | Intlayer 等效写法 |
|---|---|---|---|---|
| Simple Variable | {variableName} | Hello {name}! | Alphanumeric names, single brackets | {{name}} |
| Pluralization | {count, plural, one {...} other {...}} | {n, plural, one {# item} other {# items}} | Requires "other". # is replaced by count. | plural({ one: "1 item", other: "{{count}} items" }) |
| Exact Match Plural | =0 {...} =1 {...} | {n, plural, =0 {None} one {#} other {#}} | Takes precedence over CLDR keywords | enu({ 0: "None", 1: "1", fallback: "{{count}}" }) |
| Select (Context/Gender) | {key, select, choice1 {...} other {...}} | {gender, select, male {He} other {They}} | Case-sensitive exact string comparison | select({ male: "He", fallback: "They" }, "gender") |
| Selectordinal | {rank, selectordinal, one {#st} other {#th}} | {pos, selectordinal, one {#st} two {#nd} other {#th}} | Ordinal suffix rules per CLDR | enu({ 1: "1st", 2: "2nd", fallback: "{{pos}}th" }) |
| Number Formatting | {val, number, [style]} | {price, number, currency} | Supports percent, currency, integer styles | Intl.NumberFormat or type-safe formatting |
| Escaping | '{' and '' for apostrophes | Don''t '{'escape'}' | Single quotes escape literal blocks, '' escapes quote | Literal strings naturally supported |
Intlayer 基于编译器的架构用编译时类型安全和自动化提取取代了复杂的运行时消息解析。