Vue I18n 消息格式化与编辑器
使用管道复数(0 | 1 | 其他)、命名格式化 {name} 和链接消息 @:key 构建和测试 Vue I18n 翻译消息。
模板10
VUE-I18N 编辑器
语法有效
34 字符1 行
测试变量与实时预览
调整变量并切换语言以验证 CLDR 复数规则
语言环境:
渲染输出 (en):
Hello Lucas, welcome to Vue i18n!
导出为 Intlayer 类型安全声明
Intlayer 在编译时通过完整的 TypeScript 自动补全来验证翻译。
Vue I18n Syntax Cheat Sheet
快速语法规则以及每个模式如何映射到 Intlayer 的类型安全声明
| 功能 | 语法 | 示例 | 备注 | Intlayer 等效写法 |
|---|---|---|---|---|
| Named Formatting | {variableName} | Hello {name}! | Single braces for named parameters | {{name}} |
| List Formatting | {0}, {1}, ... | Hello {0} and {1} | Index-based positional arguments | {{0}} or named variables |
| Pipe Pluralization | no items | 1 item | {n} items | no apples | 1 apple | {n} apples | Pipes separate 0, 1, and plural forms | plural({ 0: "no apples", 1: "1 apple", other: "{{count}} apples" }) |
| Linked Messages | @:path.to.message | Home of @:brand.name | References other messages in the dictionary | TypeScript object references |
| Literal Interpolation | {'literal'} | {'hello'} {name} | Single-quoted literal inside braces | Literal strings |
Intlayer 基于编译器的架构用编译时类型安全和自动化提取取代了复杂的运行时消息解析。