{"id":12500,"library":"vue-i18n-extract","title":"Vue i18n Translation Extractor","description":"vue-i18n-extract is a development tool designed for managing `vue-i18n` localization within Vue.js projects through static code analysis. It scans Vue Single File Components (SFCs), JavaScript, and TypeScript files to identify used i18n keys and compares them against existing translation files (e.g., JSON, YAML). This helps developers find missing translations, identify unused keys that can be safely removed, and detect duplicate keys. The current stable version is 2.0.7, with an active release cadence, frequently incorporating new features and bug fixes as evidenced by recent patch releases. Its primary differentiation lies in its comprehensive static analysis approach for Vue-specific i18n usage, supporting various patterns like `$t`, `v-t`, and `Translation` components.","status":"active","version":"2.0.7","language":"javascript","source_language":"en","source_url":"https://github.com/pixari/vue-i18n-extract","tags":["javascript","typescript","vue i18n","vue","plugin","internationalization","internationalization-plugin"],"install":[{"cmd":"npm install vue-i18n-extract","lang":"bash","label":"npm"},{"cmd":"yarn add vue-i18n-extract","lang":"bash","label":"yarn"},{"cmd":"pnpm add vue-i18n-extract","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"For programmatic usage in a modern Node.js or TypeScript environment, prefer ES module imports. CommonJS `require` is generally discouraged since v2+.","wrong":"const { extractI18n } = require('vue-i18n-extract');","symbol":"extractI18n","correct":"import { extractI18n } from 'vue-i18n-extract';"},{"note":"This utility function assists in reading Vue SFCs and JavaScript/TypeScript files, returning their content for analysis. It's typically used within custom scripts.","symbol":"readVueFiles","correct":"import { readVueFiles } from 'vue-i18n-extract';"},{"note":"Used programmatically to write updated locale messages back to translation files. Ensure file paths are correct and permissions allow writing.","symbol":"writeLocaleMessages","correct":"import { writeLocaleMessages } from 'vue-i18n-extract';"}],"quickstart":{"code":"{\n  \"name\": \"my-vue-i18n-app\",\n  \"version\": \"1.0.0\",\n  \"description\": \"My Vue.js i18n project\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"i18n:report\": \"vue-i18n-extract report --vueFiles './src/**/*.?(js|ts|vue)' --languageFiles './src/locales/*.?(json|yml|yaml)' --ci\",\n    \"i18n:add\": \"vue-i18n-extract report --vueFiles './src/**/*.?(js|ts|vue)' --languageFiles './src/locales/*.?(json|yml|yaml)' --add\",\n    \"i18n:remove\": \"vue-i18n-extract report --vueFiles './src/**/*.?(js|ts|vue)' --languageFiles './src/locales/*.?(json|yml|yaml)' --remove\"\n  },\n  \"keywords\": [],\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"devDependencies\": {\n    \"vue-i18n-extract\": \"^2.0.0\"\n  }\n}","lang":"json","description":"This `package.json` excerpt demonstrates how to integrate `vue-i18n-extract` into a project using npm scripts for reporting, adding, and removing translation keys."},"warnings":[{"fix":"Review the official `vue-i18n-extract` documentation for v2.x to update `--vueFiles`, `--languageFiles`, and other options. Specifically, the `output` option was replaced by `dryRun` and `emit`.","message":"Upgrading from `v1.x` to `v2.x` introduces significant breaking changes in configuration options. Several CLI arguments and config file properties have been renamed or removed.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Always test your glob patterns with a tool like `glob-tester` or `ls -l` combined with your pattern to ensure they correctly match the intended files. Pay close attention to file extensions and nested directory structures.","message":"Incorrect glob patterns for `--vueFiles` or `--languageFiles` are a common cause of issues, leading to missing translations not being detected or files being ignored.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure all imports are done using ES module syntax (e.g., `import { extractI18n } from 'vue-i18n-extract';`). If using older Node.js versions or CJS, configure a build step (like Babel or TypeScript compilation) to transpile imports.","message":"When using `vue-i18n-extract` programmatically in an ES module (`'type': 'module'` in `package.json`) Node.js project, direct `require` statements for the library will fail with `SyntaxError: Unexpected token 'export'`.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Migrate your `vue-i18n` usage to its latest recommended patterns, such as using `$t` or `t` for pluralization (with `n` parameter) and `<i18n-t>` components. Consult the `vue-i18n` migration guide for your specific version.","message":"The underlying `vue-i18n` library has deprecated certain features like `$tc` and `tc` functions, especially for Composition API mode, and the `<i18n>` component in favor of `<i18n-t>`. While `vue-i18n-extract` aims to support various syntaxes, relying on deprecated `vue-i18n` features can lead to future compatibility issues.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Verify the `vueFiles` glob pattern in your command or configuration file. Use a tool like `ls -l './src/**/*.vue'` to confirm that files are matched by the pattern. Adjust the path or pattern as needed.","cause":"The glob pattern provided for `--vueFiles` (or in the config file) does not match any existing `.vue`, `.js`, or `.ts` files in your project. This often happens due to incorrect paths or typos in the pattern.","error":"[vue-i18n-extract] Error: vueFiles glob has no files."},{"fix":"Check the `languageFiles` glob pattern. Ensure the path is correct and the file extensions (`.json`, `.yml`, `.yaml`) are included and properly escaped if necessary (e.g., `*.?(json|yml|yaml)`).","cause":"Similar to `vueFiles` not being found, this error indicates that the glob pattern for `--languageFiles` does not match any translation files (e.g., `.json`, `.yml`, `.yaml`) at the specified location.","error":"[vue-i18n-extract] Error: languageFiles glob has no files."},{"fix":"For Node.js projects with `'type': 'module'`, use ES module imports: `import { extractI18n } from 'vue-i18n-extract';`. If sticking to CommonJS, check if a default export or different named exports are available, or use `await import('vue-i18n-extract')` for dynamic imports.","cause":"This typically occurs when attempting to use programmatic features (like `extractI18n`) in a CommonJS module context when the package is primarily designed for ES Modules, or when the named export is incorrect.","error":"TypeError: Cannot read properties of undefined (reading 'extractI18n')"}],"ecosystem":"npm"}