rollup-plugin-i18never

raw JSON →
1.1.16 verified Fri May 01 auth: no javascript

A Rollup plugin for automatic internationalization (i18n) using i18never. Version 1.1.16 ships TypeScript types and requires Rollup ^3.26.3 as a peer dependency. It provides zero-config extraction of translatable strings from source code, enabling build-time injection of locale dictionaries. Unlike runtime i18n libraries, this plugin statically replaces i18n function calls with translated strings at build time, eliminating runtime overhead. Designed for small to medium projects that want simple i18n without heavy frameworks. Released in 2023 with occasional maintenance updates.

error Error: Plugin 'i18never' does not exist? (no error string provided in docs, but common missing call issue) Actually, typical error: 'TypeError: i18never is not a function'
cause Importing the default export but treating it as a plugin object, not calling it as a function.
fix
Use plugins: [i18never({})] instead of plugins: [i18never]
error Error: Cannot find module 'i18never' (or equivalent when runtime not installed).
cause The i18never runtime package is required in the bundled output; the plugin does not bundle it.
fix
Install i18never: npm install i18never, and ensure it is imported in your source files.
error ReferenceError: t is not defined (at runtime)
cause Missing i18never runtime initialization.
fix
Import and initialize i18never before using t(): import i18never from 'i18never'; i18never.init({locale: 'en', translations: ...});
gotcha Plugin must be called as a function: i18never() not i18never
fix Use plugins: [i18never()] instead of plugins: [i18never]
gotcha The plugin only works with i18never runtime installed and configured separately; it does not provide i18n runtime. Missing i18never will cause runtime errors.
fix Install i18never package: npm install i18never, and initialize it before using t() calls.
gotcha The plugin statically replaces strings at build time; dynamic keys (e.g., t(variable)) will not be translated and may cause unexpected behavior.
fix Ensure all translatable strings are literal strings passed to t() or other configured translation functions.
deprecated Requires Rollup ^3.26.3; not officially tested with Rollup 4.x. May work but no guarantees.
fix Consider pinning Rollup to version 3.x, or check plugin compatibility with Rollup 4.
npm install rollup-plugin-i18never
yarn add rollup-plugin-i18never
pnpm add rollup-plugin-i18never

Minimal Rollup configuration using the i18never plugin to statically replace i18n function calls with translations at build time.

// Install: npm install rollup rollup-plugin-i18never
// rollup.config.js
import i18never from 'rollup-plugin-i18never';

export default {
  input: 'src/index.js',
  output: { dir: 'dist', format: 'es' },
  plugins: [
    i18never({
      // options (optional): translations, functions, locales, etc.
    })
  ]
};

// src/index.js
// Requires i18never runtime to be set up separately
import { t } from 'i18never';
console.log(t('hello'));

// Build command: npx rollup --config rollup.config.js