{"id":20789,"library":"webpack-localize-assets-plugin","title":"webpack-localize-assets-plugin","description":"Webpack plugin that localizes bundle output by replacing `__()` calls with locale-specific strings, generating separate files per locale. Current stable version is 1.5.4, released January 2023. Supports Webpack 4 and 5, with TypeScript type definitions included. Key differentiators: supports single and multiple locales, blazing fast, and offers features like source map per locale, warning on unused strings, and a custom localize compiler for advanced replacement logic. Compared to i18n-webpack-plugin, it's more flexible and actively maintained.","status":"active","version":"1.5.4","language":"javascript","source_language":"en","source_url":"https://github.com/privatenumber/webpack-localize-assets-plugin","tags":["javascript","webpack","plugin","localize","localization","i18n","internationalize","internationalization","multi-language","typescript"],"install":[{"cmd":"npm install webpack-localize-assets-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-localize-assets-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-localize-assets-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for plugin functionality","package":"webpack","optional":false}],"imports":[{"note":"This is a default export. In CommonJS, use require('webpack-localize-assets-plugin').default or const LocalizeAssetsPlugin = require('webpack-localize-assets-plugin').","wrong":"const { LocalizeAssetsPlugin } = require('webpack-localize-assets-plugin')","symbol":"LocalizeAssetsPlugin","correct":"import LocalizeAssetsPlugin from 'webpack-localize-assets-plugin'"}],"quickstart":{"code":"const LocalizeAssetsPlugin = require('webpack-localize-assets-plugin');\nconst path = require('path');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: '[name].[locale].js',\n  },\n  plugins: [\n    new LocalizeAssetsPlugin({\n      locales: {\n        en: { greeting: 'Hello' },\n        es: { greeting: 'Hola' },\n      },\n      functionName: '__',\n    }),\n  ],\n};","lang":"javascript","description":"Webpack configuration to generate locale-specific bundles using the localize plugin."},"warnings":[{"fix":"Use `[locale]` in filename, e.g., `filename: '[name].[locale].js'`.","message":"When using output.filename, you must include `[locale]` placeholder. If omitted, only the last locale will overwrite previous outputs.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always include `[locale]` for multi-locale builds.","message":"In version 1.5.0, using filenames without `[locale]` in single locale mode is allowed, but in multi-locale mode it may cause overwriting.","severity":"deprecated","affected_versions":">=1.5.0"},{"fix":"Upgrade to v1.4.2 or later.","message":"Webpack 4 compatibility: The plugin uses `Chunk.getModules` which is deprecated in Webpack 5. Fixed in v1.4.2.","severity":"breaking","affected_versions":"<1.4.2"},{"fix":"Upgrade to v1.3.0 or later; ensure `output.hashSalt` is not set.","message":"Content hash (e.g., `[contenthash]`) is not automatically unique across locales. Fixed in v1.3.0 to use `realContentHash`.","severity":"gotcha","affected_versions":"<1.3.0"},{"fix":"Upgrade to v1.5.2 or later.","message":"If locale values contain double quotes, devtool eval may break. Fixed in v1.5.1 and v1.5.2.","severity":"gotcha","affected_versions":"<1.5.1"},{"fix":"Set `warnOnUnusedString: true` in plugin options.","message":"Unused locale strings are not automatically minified. Enable `warnOnUnusedString` to detect them.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure to pass an object with `locales` property: `new LocalizeAssetsPlugin({ locales: {...} })`","cause":"Plugin instantiated without options or `locales` option is missing.","error":"TypeError: Cannot destructure property 'locales' of 'undefined' or 'null'"},{"fix":"Check that all locale keys in `locales` match the expected locale names. For single locale mode, ensure the locale key is present in options.","cause":"Locale key in `locales` does not match the key used in the build configuration or a missing locale.","error":"Error: Locale 'en' is not found in locale data"},{"fix":"Either remove the unused key from locale data or use it in code to avoid warning.","cause":"String key defined in locale but never used via `__()` function.","error":"WARNING: Unused string key 'xyz' found in locale 'en'"},{"fix":"Add `[locale]` to output.filename and ensure `output.realContentHash` is true (Webpack 5).","cause":"Output filename doesn't include `[locale]` or content hash collision.","error":"Error: contenthash is not unique across locales"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}