免费工具

    Intlayer 消息格式化与编辑器

    利用 {{var}} 插值、t()、plural()、enu()、select()、cond() 和 Markdown 构建、测试并验证类型安全的 Intlayer 内容声明。

    模板18
    INTLAYER 编辑器
    语法有效
    36 字符1

    测试变量与实时预览

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

    语言环境:
    渲染输出 (en):
    Hello Alex, welcome to Intlayer!
    导出为 Intlayer 类型安全声明
    import { type Dictionary } from 'intlayer';const convertedMessageContent = {  key: 'converted-message',  content: 'Hello {{name}}, welcome to Intlayer!',} satisfies Dictionary;export default convertedMessageContent;
    Intlayer 在编译时通过完整的 TypeScript 自动补全来验证翻译。

    Intlayer Message Format Syntax Cheat Sheet

    快速语法规则以及每个模式如何映射到 Intlayer 的类型安全声明

    功能语法示例备注Intlayer 等效写法
    Variable Interpolation{{variableName}}Hello {{name}}!Double curly braces for dynamic parameter insertionuseIntlayer(key).name or resolveMessage()
    Multilingual Translationt({ en: "...", fr: "..." })t({ en: "Hello", fr: "Bonjour" })Locale-keyed translations with type safety and fallbackt({ [locale]: string })
    Pluralization (plural)plural({ one: "...", other: "..." })plural({ one: "1 item", other: "{{count}} items" })CLDR cardinal plural rules with automatic count lookupplural({ [category]: string })
    Exact Enumeration (enu)enu({ 0: "...", 1: "...", fallback: "..." })enu({ 0: "Zero", 1: "One", fallback: "{{count}}" })Exact numeric matching with fallback for remaining countsenu({ [number]: string, fallback })
    Dynamic Selection (select)select({ key: "...", fallback: "..." }, "variable")select({ admin: "Admin", fallback: "User" }, "role")Branch on any custom string variable discriminatorselect({ [key]: string }, variableKey)
    Gender Agreement (gender)gender({ male: "...", female: "...", fallback: "..." })gender({ male: "He", female: "She", fallback: "They" })Grammatical gender concordance with automatic lookupgender({ male, female, fallback })
    Boolean Condition (cond)cond({ true: "...", false: "..." })cond({ true: "Logged In", false: "Guest" })Evaluates boolean state conditionscond({ true: string, false: string })
    Markdown Content (md)md("# ...\n**bold**")md("# Title\n\n**Bold** {{variable}}")Rich markdown rendered to React / HTML nodesmd(markdownString)
    Embedded HTML (html)html("<tag>...</tag>")html("<p>Visit <a href=\"/\">home</a></p>")Embedded safe HTML markup for links and formattinghtml(htmlString)
    Intlayer 基于编译器的架构用编译时类型安全和自动化提取取代了复杂的运行时消息解析。
    Intlayer 生态系统

    无需再为复杂的语法烦恼

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