vue-i18n-skilld
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseintlify/vue-i18n vue-i18n
vue-i18nintlify/vue-i18n vue-i18n
vue-i18nVersion: 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— deprecated in v11 due to limited optimization benefits in Vue 3; scheduled for removal in v12 source
v-t -
BREAKING:and
tc— dropped in v11 for Legacy API mode; use pluralization support in$tcandtinstead source$t -
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:and
$tSignatures — Legacy API mode signatures changed in v10 to match Composition API mode; positional locale args now require options object sourcet -
NEW: Generated Locale Types — v10 adds support for extending locale types viafor better TypeScript inference source
GeneratedTypeConfig -
BREAKING: ModuloSyntax — named interpolation using modulo syntax dropped in v10; use standard
%interpolation source{} -
BREAKING:— dropped in v10 following Vue 2 EOL source
vue-i18n-bridge -
BREAKING:Option — dropped in v10; was previously used for Legacy to Composition API migration on v9 source
allowComposition
Also changed: GA v10 · Configurable type new v11.1.0 · property deprecated v11 · accepts key type v11.0.0 · Part options support & new v11.1.4
petite-vue-i18n$i18nmodetmDefineLocaleMessage$n$d本节记录了各版本的API变更信息——优先关注近期的大版本/小版本更新。
-
已废弃:Legacy API模式 — 在v11中废弃,优先推荐Composition API;计划在v12中移除 来源
-
已废弃:自定义指令— 由于在Vue 3中优化收益有限,于v11中废弃;计划在v12中移除 来源
v-t -
破坏性变更:和
tc— 为适配Legacy API模式,于v11中移除;请改用$tc和t中的复数化支持 来源$t -
新增功能:Vue 3 Vapor模式 — 在v11.2.0中添加了对Vue 3 vapor模式的兼容性支持 来源
-
破坏性变更:JIT编译 — 在v10中默认启用,以解决CSP问题并支持动态资源 来源
-
破坏性变更:和
$t签名 — 为匹配Composition API模式,v10中修改了Legacy API模式下的签名;位置化区域参数现在需要传入选项对象 来源t -
新增功能:生成式区域类型 — v10添加了通过扩展区域类型的支持,以实现更好的TypeScript类型推断 来源
GeneratedTypeConfig -
破坏性变更:取模语法 — v10中移除了使用取模语法的命名插值;请使用标准的
%插值方式 来源{} -
破坏性变更:— 随着Vue 2停止维护,v10中移除了该桥接工具 来源
vue-i18n-bridge -
破坏性变更:选项 — v10中移除了该选项;它此前用于v9版本中从Legacy API到Composition API的迁移 来源
allowComposition
其他变更: v10正式版发布 · 可配置类型(v11.1.0新增) · 属性已废弃(v11) · 支持键类型(v11.0.0) · 和支持部分选项(v11.1.4新增)
petite-vue-i18n$i18nmodetmDefineLocaleMessage$n$dBest Practices
最佳实践
-
Prefer Composition API mode () for all new projects — Legacy API mode is deprecated in v11 and will be removed in v12 source
legacy: false -
Usefunction or
t()component over the<i18n-t>directive — the directive is deprecated in v11 and lacks IDE support for key completion sourcev-t -
Define global resource schemas using,
DefineLocaleMessage, andDefineDateTimeFormatinterfaces — enables automatic type inference and key completion inDefineNumberFormatwithout passing type parameters sourceuseI18n -
Use(Resolve Translation) when processing locale messages retrieved via
rt()— ensures proper resolution of nested structures and pluralization for programmatically accessed messagestm() -
Enablewhen using
escapeParameter: truewith translations containing user input — prevents XSS by escaping interpolation parameters and neutralizing dangerous HTML attributesv-html -
Explicitly configureand
__VUE_I18N_FULL_INSTALL__feature flags — setting these to__VUE_I18N_LEGACY_API__in bundler configuration enables better tree-shaking and reduces bundle size sourcefalse -
Pre-compile locale messages using— improves performance by using AST/Functions and ensures CSP compliance by avoiding
@intlify/unplugin-vue-i18nduring runtime compilation sourceeval -
Implement lazy loading for locale messages using dynamicand
import()— reduces initial bundle size by loading language resources only when needed (e.g., in router guards) sourcesetLocaleMessage() -
Synchronize the
htmlattribute andlangheaders when switching locales — ensures accessibility (screen readers) and consistent language handling for server-side requests sourceAccept-Language
-
所有新项目优先使用Composition API模式()——Legacy API模式在v11中已废弃,将在v12中移除 来源
legacy: false -
优先使用函数或
t()组件,而非<i18n-t>指令——该指令在v11中已废弃,且缺乏IDE的键补全支持 来源v-t -
使用、
DefineLocaleMessage和DefineDateTimeFormat接口定义全局资源Schema——无需传入类型参数,即可在DefineNumberFormat中实现自动类型推断和键补全 来源useI18n -
当处理通过获取的区域消息时,使用
tm()(Resolve Translation)——确保对以编程方式访问的消息进行正确的嵌套结构解析和复数化处理rt() -
当在包含用户输入的翻译内容中使用时,启用
v-html——通过转义插值参数并中和危险HTML属性来防止XSS攻击escapeParameter: true -
显式配置和
__VUE_I18N_FULL_INSTALL__功能标志——在打包工具配置中将这些设置为__VUE_I18N_LEGACY_API__,可实现更优的Tree Shaking并减小包体积 来源false -
使用预编译区域消息——通过使用AST/函数提升性能,并通过避免运行时编译中的
@intlify/unplugin-vue-i18n确保CSP合规 来源eval -
使用动态和
import()实现区域消息的懒加载——仅在需要时加载语言资源(例如在路由守卫中),从而减小初始包体积 来源setLocaleMessage() -
切换区域时同步的
html属性和lang请求头——确保无障碍访问(屏幕阅读器)和服务器端请求的语言处理一致性 来源Accept-Language