免费工具

    ICU 消息格式化与编辑器

    使用实时预览、100+ 模板和多语言 CLDR 复数验证来构建、测试和验证 ICU MessageFormat 字符串。

    模板50
    ICU 编辑器
    语法有效
    14 字符1

    测试变量与实时预览

    调整变量并切换语言以验证 CLDR 复数规则

    语言环境:
    渲染输出 (en):
    Hello, Alex!
    导出为 Intlayer 类型安全声明
    import { type Dictionary } from 'intlayer';const convertedMessageContent = {  key: 'converted-message',  content: 'Hello, {{name}}!',} satisfies Dictionary;export default convertedMessageContent;
    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 keywordsenu({ 0: "None", 1: "1", fallback: "{{count}}" })
    Select (Context/Gender){key, select, choice1 {...} other {...}}{gender, select, male {He} other {They}}Case-sensitive exact string comparisonselect({ male: "He", fallback: "They" }, "gender")
    Selectordinal{rank, selectordinal, one {#st} other {#th}}{pos, selectordinal, one {#st} two {#nd} other {#th}}Ordinal suffix rules per CLDRenu({ 1: "1st", 2: "2nd", fallback: "{{pos}}th" })
    Number Formatting{val, number, [style]}{price, number, currency}Supports percent, currency, integer stylesIntl.NumberFormat or type-safe formatting
    Escaping'{' and '' for apostrophesDon''t '{'escape'}'Single quotes escape literal blocks, '' escapes quoteLiteral strings naturally supported
    Intlayer 基于编译器的架构用编译时类型安全和自动化提取取代了复杂的运行时消息解析。
    Intlayer 生态系统

    无需再为复杂的语法烦恼

    Intlayer 通过编译时类型安全、自动组件提取和无缝 CMS 集成,让国际化成为愉悦的开发体验。