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.
npm install webpack-localize-assets-pluginVerified import paths — ran on the pinned version, not inferred.
Webpack configuration to generate locale-specific bundles using the localize plugin.
Use `[locale]` in filename, e.g., `filename: '[name].[locale].js'`.
Always include `[locale]` for multi-locale builds.
Upgrade to v1.4.2 or later.
Upgrade to v1.3.0 or later; ensure `output.hashSalt` is not set.
Upgrade to v1.5.2 or later.
Set `warnOnUnusedString: true` in plugin options.
Ensure to pass an object with `locales` property: `new LocalizeAssetsPlugin({ locales: {...} })`Check that all locale keys in `locales` match the expected locale names. For single locale mode, ensure the locale key is present in options.
Either remove the unused key from locale data or use it in code to avoid warning.
Add `[locale]` to output.filename and ensure `output.realContentHash` is true (Webpack 5).