{"id":22538,"library":"vite-auto-i18n-plugin","title":"vite-auto-i18n-plugin","description":"A Vite/Rollup plugin for automatic i18n translation, version 1.1.16, with active releases. Supports Vue2/3, React, and other JS frameworks, integrating multiple translation services (Google, Youdao, custom) without modifying source code. Compatible with Vite, Webpack, Rsbuild, and Rollup. Detects translatable text and generates language packs automatically. Requires Node >=14.18.0 and ships TypeScript types.","status":"active","version":"1.1.16","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/wenps/auto-i18n-translation-plugins","tags":["javascript","i18n","auto i18n","vite i18n","vue i18n","react i18n","typescript"],"install":[{"cmd":"npm install vite-auto-i18n-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add vite-auto-i18n-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-auto-i18n-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Requires vue template compiler options for Vue projects","package":"vue","optional":true}],"imports":[{"note":"Package is ESM-only; default export is the plugin function.","wrong":"const vitePluginsAutoI18n = require('vite-auto-i18n-plugin')","symbol":"default","correct":"import vitePluginsAutoI18n from 'vite-auto-i18n-plugin'"},{"note":"Named export for the Youdao translator class.","wrong":"const { YoudaoTranslator } = require('vite-auto-i18n-plugin')","symbol":"YoudaoTranslator","correct":"import { YoudaoTranslator } from 'vite-auto-i18n-plugin'"},{"note":"Translator is an interface/type; use import type for type-only usage.","wrong":"import { Translator } from 'vite-auto-i18n-plugin'","symbol":"type Translator","correct":"import type { Translator } from 'vite-auto-i18n-plugin'"}],"quickstart":{"code":"import vitePluginsAutoI18n, { YoudaoTranslator } from 'vite-auto-i18n-plugin';\nimport vue from '@vitejs/plugin-vue';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  plugins: [\n    vue({\n      template: {\n        compilerOptions: {\n          hoistStatic: false,\n          cacheHandlers: false\n        }\n      }\n    }),\n    vitePluginsAutoI18n({\n      translator: new YoudaoTranslator({\n        appId: process.env.YOUDAO_APP_ID ?? '',\n        appKey: process.env.YOUDAO_APP_KEY ?? ''\n      })\n    })\n  ]\n});","lang":"typescript","description":"Basic Vite configuration integrating the auto-i18n plugin with Vue and Youdao translation service."},"warnings":[{"fix":"Set hoistStatic: false and cacheHandlers: false in vue template compilerOptions.","message":"Requires disabling Vue 3 template hoisting and caching for correct translation injection","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Obtain valid appId and appKey from Youdao translation service.","message":"YoudaoTranslator demo keys are rate-limited and often exhausted; must provide own keys.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use v-if re-mount pattern as shown in docs, or trigger re-render manually.","message":"Language switching via $changeLang requires component re-render (e.g., v-if toggle)","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use import syntax or configure bundler for ESM.","message":"ESM-only; does not support require()","severity":"breaking","affected_versions":">=1.0.23"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Replace require with import; ensure project is configured for ESM.","cause":"Using require() in an ESM context","error":"Error: Dynamic require of 'vite-auto-i18n-plugin' is not supported"},{"fix":"Ensure plugin is properly loaded and $changeLang is used after DOM ready.","cause":"$changeLang not available before plugin initialization or outside browser","error":"TypeError: $changeLang is not a function"},{"fix":"Set hoistStatic: false and cacheHandlers: false in vue plugin options.","cause":"Vue template hoisting or caching enabled","error":"Translation not applied after build"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}