Vite automatic translation plugin for internationalizing frontend applications (Vue2/3, React, etc.) without modifying source code. Current stable version: 1.1.9. Integrates Google Translate (default), Youdao Translate, and Baidu Translate, with support for custom translators. Compatible with Vite, Webpack, and Rollup. Provides intelligent text detection and automated locale file generation. Note: Youdao API keys in demo are exhausted; users must obtain their own.
npm install vite-gc-i18n-pluginNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configure Vite with the auto-translation plugin using Youdao translator. Disable Vue template hoisting to ensure all strings are detected.
Register at Youdao AI Open Platform and replace appId/appKey with your own.
Set a valid HTTP/SOCKS proxy via translator options or switch to Youdao/Baidu translator.
Set `hoistStatic: false` and `cacheHandlers: false` in Vue plugin options.
Use `window.$changeLang(lang)` to switch language without full page reload.
Place the locale directory (`lang/`) inside your project source. Check generated files after build.
Add `translator: new GoogleTranslator() // or YoudaoTranslator(...)` to plugin settings.
Ensure `appId` and `appKey` are provided, e.g., from environment variables.
Run the build to generate locale files. Ensure the `lang` directory exists in project root.