i18next CLI

1.56.2 · active · verified Wed Apr 22

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.

Common errors

Warnings

Install

Imports

Quickstart

Installs the CLI, sets up a basic TypeScript configuration file, and then demonstrates checking translation status and extracting keys.

npm install --save-dev i18next-cli

// Create i18next.config.ts in your project root
// This enables TypeScript support and robust configuration.
// For zero-config quick testing, skip this step and run 'npx i18next-cli status'.
import { defineConfig } from 'i18next-cli';

export default defineConfig({
  locales: ['en', 'de'],
  extract: {
    input: ['src/**/*.{js,jsx,ts,tsx}'],
    output: 'public/locales/{{language}}/{{namespace}}.json',
  },
  // For more complex setups, e.g., with React components in 'components'
  // and pages in 'pages', you might extend the input array.
  // lint: { ... }, // Add linting rules
  // sync: { ... }, // Add synchronization options
});

// Check the current translation status of your project
npx i18next-cli status

// Extract translation keys based on your configuration
npx i18next-cli extract

view raw JSON →