vue-i18n-skilld

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

intlify/vue-i18n
vue-i18n

intlify/vue-i18n
vue-i18n

Version: 11.2.8 (Dec 2025) Deps: @vue/devtools-api@^6.5.0, @intlify/core-base@11.2.8, @intlify/shared@11.2.8 Tags: rc: 9.0.0-rc.9 (Feb 2021), alpha: 9.2.0-alpha.9 (Jul 2021), legacy: 8.28.2 (Oct 2022), edge: 9.3.0-beta.14-77e850b (Jan 2023), beta: 9.3.0-beta.27 (Aug 2023), next: 12.0.0-alpha.3 (Jul 2025), stable: 11.1.10 (Jul 2025), legacy10: 10.0.8 (Jul 2025), stable9: 9.14.5 (Jul 2025), legacy9: 9.14.5 (Jul 2025), latest: 11.2.8 (Dec 2025)
References: Docs — API reference, guides • GitHub Issues — bugs, workarounds, edge cases • GitHub Discussions — Q&A, patterns, recipes • Releases — changelog, breaking changes, new APIs
**版本:**11.2.8(2025年12月) 依赖:@vue/devtools-api@^6.5.0, @intlify/core-base@11.2.8, @intlify/shared@11.2.8 **版本标签:**rc: 9.0.0-rc.9(2021年2月), alpha: 9.2.0-alpha.9(2021年7月), legacy: 8.28.2(2022年10月), edge: 9.3.0-beta.14-77e850b(2023年1月), beta: 9.3.0-beta.27(2023年8月), next: 12.0.0-alpha.3(2025年7月), stable: 11.1.10(2025年7月), legacy10: 10.0.8(2025年7月), stable9: 9.14.5(2025年7月), legacy9: 9.14.5(2025年7月), latest: 11.2.8(2025年12月)
参考资源:文档 — API参考、使用指南 • GitHub Issues — 问题反馈、解决方案、边缘场景 • GitHub Discussions — 问答、模式参考、实践方案 • 版本发布记录 — 更新日志、破坏性变更、新API

API Changes

API变更

This section documents version-specific API changes — prioritize recent major/minor releases.
  • DEPRECATED: Legacy API mode — deprecated in v11 for Composition API preference; scheduled for removal in v12 source
  • DEPRECATED: Custom Directive
    v-t
    — deprecated in v11 due to limited optimization benefits in Vue 3; scheduled for removal in v12 source
  • BREAKING:
    tc
    and
    $tc
    — dropped in v11 for Legacy API mode; use pluralization support in
    t
    and
    $t
    instead source
  • NEW: Vue 3 Vapor Mode — added compatibility for Vue 3 vapor mode in v11.2.0 source
  • BREAKING: JIT Compilation — enabled by default in v10 to solve CSP issues and support dynamic resources source
  • BREAKING:
    $t
    and
    t
    Signatures — Legacy API mode signatures changed in v10 to match Composition API mode; positional locale args now require options object source
  • NEW: Generated Locale Types — v10 adds support for extending locale types via
    GeneratedTypeConfig
    for better TypeScript inference source
  • BREAKING: Modulo
    %
    Syntax — named interpolation using modulo syntax dropped in v10; use standard
    {}
    interpolation source
  • BREAKING:
    vue-i18n-bridge
    — dropped in v10 following Vue 2 EOL source
  • BREAKING:
    allowComposition
    Option — dropped in v10; was previously used for Legacy to Composition API migration on v9 source
Also changed:
petite-vue-i18n
GA v10 · Configurable
$i18n
type new v11.1.0 ·
mode
property deprecated v11 ·
tm
accepts
DefineLocaleMessage
key type v11.0.0 · Part options support
$n
&
$d
new v11.1.4
本节记录了各版本的API变更信息——优先关注近期的大版本/小版本更新。
  • 已废弃:Legacy API模式 — 在v11中废弃,优先推荐Composition API;计划在v12中移除 来源
  • 已废弃:自定义指令
    v-t
    — 由于在Vue 3中优化收益有限,于v11中废弃;计划在v12中移除 来源
  • 破坏性变更:
    tc
    $tc
    — 为适配Legacy API模式,于v11中移除;请改用
    t
    $t
    中的复数化支持 来源
  • 新增功能:Vue 3 Vapor模式 — 在v11.2.0中添加了对Vue 3 vapor模式的兼容性支持 来源
  • 破坏性变更:JIT编译 — 在v10中默认启用,以解决CSP问题并支持动态资源 来源
  • 破坏性变更:
    $t
    t
    签名 — 为匹配Composition API模式,v10中修改了Legacy API模式下的签名;位置化区域参数现在需要传入选项对象 来源
  • 新增功能:生成式区域类型 — v10添加了通过
    GeneratedTypeConfig
    扩展区域类型的支持,以实现更好的TypeScript类型推断 来源
  • 破坏性变更:取模
    %
    语法 — v10中移除了使用取模语法的命名插值;请使用标准的
    {}
    插值方式 来源
  • 破坏性变更:
    vue-i18n-bridge
    — 随着Vue 2停止维护,v10中移除了该桥接工具 来源
  • 破坏性变更:
    allowComposition
    选项 — v10中移除了该选项;它此前用于v9版本中从Legacy API到Composition API的迁移 来源
其他变更:
petite-vue-i18n
v10正式版发布 · 可配置
$i18n
类型(v11.1.0新增) ·
mode
属性已废弃(v11) ·
tm
支持
DefineLocaleMessage
键类型(v11.0.0) ·
$n
$d
支持部分选项(v11.1.4新增)

Best Practices

最佳实践

  • Prefer Composition API mode (
    legacy: false
    ) for all new projects — Legacy API mode is deprecated in v11 and will be removed in v12 source
  • Use
    t()
    function or
    <i18n-t>
    component over the
    v-t
    directive — the directive is deprecated in v11 and lacks IDE support for key completion source
  • Define global resource schemas using
    DefineLocaleMessage
    ,
    DefineDateTimeFormat
    , and
    DefineNumberFormat
    interfaces — enables automatic type inference and key completion in
    useI18n
    without passing type parameters source
  • Use
    rt()
    (Resolve Translation) when processing locale messages retrieved via
    tm()
    — ensures proper resolution of nested structures and pluralization for programmatically accessed messages
  • Enable
    escapeParameter: true
    when using
    v-html
    with translations containing user input — prevents XSS by escaping interpolation parameters and neutralizing dangerous HTML attributes
  • Explicitly configure
    __VUE_I18N_FULL_INSTALL__
    and
    __VUE_I18N_LEGACY_API__
    feature flags — setting these to
    false
    in bundler configuration enables better tree-shaking and reduces bundle size source
  • Pre-compile locale messages using
    @intlify/unplugin-vue-i18n
    — improves performance by using AST/Functions and ensures CSP compliance by avoiding
    eval
    during runtime compilation source
  • Implement lazy loading for locale messages using dynamic
    import()
    and
    setLocaleMessage()
    — reduces initial bundle size by loading language resources only when needed (e.g., in router guards) source
  • Synchronize the
    html
    lang
    attribute and
    Accept-Language
    headers when switching locales — ensures accessibility (screen readers) and consistent language handling for server-side requests source
  • 所有新项目优先使用Composition API模式(
    legacy: false
    )——Legacy API模式在v11中已废弃,将在v12中移除 来源
  • 优先使用
    t()
    函数或
    <i18n-t>
    组件,而非
    v-t
    指令——该指令在v11中已废弃,且缺乏IDE的键补全支持 来源
  • 使用
    DefineLocaleMessage
    DefineDateTimeFormat
    DefineNumberFormat
    接口定义全局资源Schema——无需传入类型参数,即可在
    useI18n
    中实现自动类型推断和键补全 来源
  • 当处理通过
    tm()
    获取的区域消息时,使用
    rt()
    (Resolve Translation)——确保对以编程方式访问的消息进行正确的嵌套结构解析和复数化处理
  • 当在包含用户输入的翻译内容中使用
    v-html
    时,启用
    escapeParameter: true
    ——通过转义插值参数并中和危险HTML属性来防止XSS攻击
  • 显式配置
    __VUE_I18N_FULL_INSTALL__
    __VUE_I18N_LEGACY_API__
    功能标志——在打包工具配置中将这些设置为
    false
    ,可实现更优的Tree Shaking并减小包体积 来源
  • 使用
    @intlify/unplugin-vue-i18n
    预编译区域消息——通过使用AST/函数提升性能,并通过避免运行时编译中的
    eval
    确保CSP合规 来源
  • 使用动态
    import()
    setLocaleMessage()
    实现区域消息的懒加载——仅在需要时加载语言资源(例如在路由守卫中),从而减小初始包体积 来源
  • 切换区域时同步
    html
    lang
    属性和
    Accept-Language
    请求头——确保无障碍访问(屏幕阅读器)和服务器端请求的语言处理一致性 来源