rollup-plugin-i18next-conv
raw JSON → 10.0.0 verified Mon Apr 27 auth: no javascript
A Rollup plugin that imports PO (gettext) files as i18next-compatible JSON objects, enabling seamless integration of i18next translation workflows into your build. Version 10.0.0 requires Node >=20 and supports Rollup 2/3/4 and i18next-conv >=14. Released about every 6 months with breaking changes tied to Node EOL. Differentiators: deterministic locale extraction from file paths, customizable include/exclude patterns, and passthrough of all i18next-conv options. Unlike alternatives, it focuses exclusively on PO file conversion with zero runtime overhead.
Common errors
error Error: Cannot find module 'rollup-plugin-i18next-conv' ↓
cause Missing npm install or incorrect import path.
fix
Run
npm install --save-dev rollup-plugin-i18next-conv and ensure package.json includes it. error TypeError: i18next is not a function ↓
cause Using named import `{ i18next }` instead of default import.
fix
Change to
import i18next from 'rollup-plugin-i18next-conv'. error Error: The 'i18next-conv' package is required. Please install it. ↓
cause Missing peer dependency i18next-conv.
fix
Run
npm install --save-dev i18next-conv. error Error [ERR_REQUIRE_ESM]: require() of ES Module ↓
cause Using require() on an ESM-only package (>= v7).
fix
Switch to import syntax or use dynamic import().
Warnings
breaking Node.js >=20 required since v10.0.0 ↓
fix Upgrade Node.js to version 20 or later.
breaking ESM-only module; CommonJS require() no longer works ↓
fix Use import statements or dynamic import() instead of require().
breaking Minimum peer dependency i18next-conv >=14 required since v8.0.0 ↓
fix Update i18next-conv to version 14 or higher.
breaking Rollup 3 support dropped; v8.1.0 added Rollup 4 support ↓
fix Check that your Rollup version is ^2.0.0, ^3.0.0, or ^4.0.0.
deprecated Rollup 2 support deprecated; future versions may require Rollup >=3 ↓
fix Migrate to Rollup 3 or 4.
gotcha Default locale extraction assumes locale folder is third segment from end of path ↓
fix Override determineLocale function if your folder structure differs.
Install
npm install rollup-plugin-i18next-conv yarn add rollup-plugin-i18next-conv pnpm add rollup-plugin-i18next-conv Imports
- default wrong
const i18next = require('rollup-plugin-i18next-conv').defaultcorrectimport i18next from 'rollup-plugin-i18next-conv' - i18next wrong
import { i18next } from 'rollup-plugin-i18next-conv'correctimport i18next from 'rollup-plugin-i18next-conv' - require (CJS) wrong
const i18next = require('rollup-plugin-i18next-conv')correctconst i18next = await import('rollup-plugin-i18next-conv')
Quickstart
// rollup.config.js
import i18next from 'rollup-plugin-i18next-conv';
import path from 'path';
export default {
input: 'src/main.js',
output: {
file: 'dist/bundle.js',
format: 'iife'
},
plugins: [
i18next({
include: ['**/locale/**/*.po'],
exclude: ['node_modules/**'],
determineLocale: (filename) => filename.split(path.sep).slice(-3)[0],
keyseparator: '$$'
})
]
};