{"id":16833,"library":"i18next-cli","title":"i18next CLI","description":"i18next-cli is a unified, high-performance command-line interface tool for the i18next internationalization ecosystem, currently at version 1.56.2. It leverages the Rust-based SWC parser for rapid static analysis, providing features such as automatic translation key extraction from JavaScript and TypeScript files, generation of TypeScript type definitions for improved developer experience, synchronization of locale files, and intelligent linting to detect hardcoded strings. The tool is designed to consolidate various i18next-related static analysis tasks into a single, cohesive workflow, replacing disparate scripts and older tools like `i18next-parser`. It also features a modern plugin architecture for extensibility to custom file types and workflows, and offers seamless integration with translation management platforms like Locize.","status":"active","version":"1.56.2","language":"javascript","source_language":"en","source_url":"https://github.com/i18next/i18next-cli","tags":["javascript","i18next","swc","cli","typescript"],"install":[{"cmd":"npm install i18next-cli","lang":"bash","label":"npm"},{"cmd":"yarn add i18next-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add i18next-cli","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Used for configuring the i18next-cli in an `i18next.config.ts` file. Primarily an ESM pattern for configuration.","wrong":"const defineConfig = require('i18next-cli').defineConfig;","symbol":"defineConfig","correct":"import { defineConfig } from 'i18next-cli';"},{"note":"The package is primarily a CLI tool and is typically invoked via `npx` or a script defined in `package.json`.","wrong":"import { run } from 'i18next-cli'; // Incorrect library usage","symbol":"CLI usage","correct":"npx i18next-cli <command>"}],"quickstart":{"code":"npm install --save-dev i18next-cli\n\n// Create i18next.config.ts in your project root\n// This enables TypeScript support and robust configuration.\n// For zero-config quick testing, skip this step and run 'npx i18next-cli status'.\nimport { defineConfig } from 'i18next-cli';\n\nexport default defineConfig({\n  locales: ['en', 'de'],\n  extract: {\n    input: ['src/**/*.{js,jsx,ts,tsx}'],\n    output: 'public/locales/{{language}}/{{namespace}}.json',\n  },\n  // For more complex setups, e.g., with React components in 'components'\n  // and pages in 'pages', you might extend the input array.\n  // lint: { ... }, // Add linting rules\n  // sync: { ... }, // Add synchronization options\n});\n\n// Check the current translation status of your project\nnpx i18next-cli status\n\n// Extract translation keys based on your configuration\nnpx i18next-cli extract\n","lang":"typescript","description":"Installs the CLI, sets up a basic TypeScript configuration file, and then demonstrates checking translation status and extracting keys."},"warnings":[{"fix":"Utilize the `npx i18next-cli init` command to create a new configuration file, or refer to the `i18next.config.ts` documentation for the new format. Review existing i18next-parser configurations to translate them to the new `i18next-cli` config structure.","message":"i18next-cli is a 'complete reimagining' of the i18next static analysis toolchain. Users migrating from older tools like `i18next-parser` or custom scripts will need to adopt a new configuration format and workflow. While it offers migration helpers, direct compatibility is not guaranteed.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"For non-JavaScript/TypeScript file types, a dedicated plugin is required. Check the documentation for available plugins or create a custom plugin to handle specific templating languages or frameworks.","message":"Key extraction is limited by default to JavaScript and TypeScript files (.js, .jsx, .ts, .tsx). Simply adding other file extensions (e.g., .vue, .svelte, .pug) to the `extract.input` configuration array will NOT enable extraction from those formats.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade your Node.js environment to version 22 or newer. Use a Node Version Manager (NVM) like `nvm install 22 && nvm use 22` to manage multiple Node.js versions.","message":"The package requires Node.js version 22 or higher. Older Node.js versions are not supported and will lead to execution failures.","severity":"breaking","affected_versions":"<1.56.2"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Update your Node.js environment to version 22 or newer. For example, using nvm: `nvm install 22 && nvm use 22`.","cause":"Attempting to run i18next-cli with an unsupported Node.js version.","error":"Error: Node.js version is too old. i18next-cli requires Node.js >= 22."},{"fix":"Verify that the glob patterns in `i18next.config.ts` under `extract.input` correctly match your project's source files. Ensure file paths are relative to the config file's location.","cause":"The `extract.input` configuration array does not correctly point to source files, or the specified files do not exist.","error":"i18next-cli: No input files found for extraction. Please check your 'extract.input' configuration."},{"fix":"Install or create a `i18next-cli` plugin for the specific file type (e.g., '.vue' files) you wish to extract keys from. Consult the 'Plugin System' section in the documentation.","cause":"Attempting to extract translation keys from a non-JavaScript/TypeScript file type without a specific plugin.","error":"i18next-cli: Could not extract keys from 'path/to/my-component.vue'. Only JS/TS files are supported by default."}],"ecosystem":"npm","meta_description":null}