One‑Click i18n Solutions for Vue and React: Compare Three Zero‑Intrusion Tools
The article reviews three zero‑intrusion, MIT‑licensed i18n toolkits—i18n‑auto‑extractor, auto‑i18n‑translation‑plugins, and i18n‑cli—detailing their features, installation steps, code examples, and scenario‑based recommendations for new or legacy Vue/React projects.
i18n‑auto‑extractor
Wrap literal strings with $at(). The tool extracts them, generates locale JSON files, and uses built‑in Google Translate for over 100 languages. Zero‑configuration after installation.
Installation & usage
npm i -D i18n-auto-extractor
npx i18n-auto-extractor # generates config file const title = $at('欢迎来到我的网站')After build the tool creates a locales/ directory:
locales/
├─ zh.json // original Chinese
├─ en.json // auto‑translated
├─ fr.json // …auto‑i18n‑translation‑plugins
Provides Babel‑based zero‑intrusion plugins for Vite, Webpack and Rollup that translate source‑code Chinese strings without writing $t(). Supports Google, Youdao and Baidu translators and performs incremental builds.
Vite example
npm i -D vite-auto-i18n-plugin@^1.0.23 // vite.config.ts
import viteAutoI18n from 'vite-auto-i18n-plugin'
export default defineConfig({
plugins: [
vue(),
viteAutoI18n({
targetLangList: ['en', 'ja', 'ko'],
translator: new YoudaoTranslator({ appId: 'xxx', appKey: 'xxx' })
})
]
})Build generates lang/index.json for import.
i18n‑cli
Command‑line tool that scans a project, replaces Chinese literals with t('...'), and outputs locale JSON files. Supports Baidu, Google and Youdao translators and an incremental mode.
Two‑step usage
npm i -g @ifreeovo/i18n-extract-cli
it --locales en,ja # full translation
it --incremental # only new stringsSample output:
// locales/zh-CN.json
{ "a1b2c3": "提交订单" }
// locales/en.json
{ "a1b2c3": "Submit Order" }Scenario selection guide
New project, long‑term maintenance – use i18n‑auto‑extractor (requires wrapping strings but remains maintainable).
Legacy project, need English version within days – use auto‑i18n‑translation‑plugins (no source changes).
Collaboration with product/translation team – use i18n‑cli (CLI + Excel workflow).
Summary
Skip writing $t() → auto‑i18n‑translation‑plugins .
Wrap strings with $at() for long‑term ease → i18n‑auto‑extractor .
Quick CLI scan with Excel collaboration → i18n‑cli .
All three tools are MIT‑licensed open source.
GitHub links
i18n‑auto‑extractor: https://github.com/qianyuanjia/i18n-auto-extractor auto‑i18n‑translation‑plugins: https://github.com/auto-i18n/auto-i18n-translation-plugins i18n‑cli:
https://github.com/IFreeOvO/i18n-cliSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Full-Stack Cultivation Path
Focused on sharing practical tech content about TypeScript, Vue 3, front-end architecture, and source code analysis.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
