# i18n-chunks-webpack-plugin

> Look in all chunks for files that match a rule and then, associate and generate translations files with it.

Latest version **0.1.1** (published 2018-03-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install i18n-chunks-webpack-plugin
pnpm add i18n-chunks-webpack-plugin
yarn add i18n-chunks-webpack-plugin
bun add i18n-chunks-webpack-plugin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2018-03-03 |
| First published | 2018-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4.3 < 5.0.0 \|\| >= 5.10 |
| Dependencies | 0 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | AsyncWizard |
| Maintainers | asyncwizard |
| Keywords | i18n, webpack-plugin, chunks |

## Links

- npm: https://www.npmjs.com/package/i18n-chunks-webpack-plugin
- Repository: https://github.com/AsyncWizard/i18n-chunks-webpack-plugin
- Homepage: https://github.com/AsyncWizard/i18n-chunks-webpack-plugin#readme
- Issues: https://github.com/AsyncWizard/i18n-chunks-webpack-plugin/issues
- npm.io page: https://npm.io/package/i18n-chunks-webpack-plugin

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2018-03-03
- 0.1.0 — 2018-03-03

## README

# i18n-chunks-webpack-plugin
Look in all chunks for files that match a rule and then, associate and generate translations files with it.
If you have lazy loaded files, the plugin will generate separates files for each chunks and each langs defined by the rules.

## Installation

Install with npm:

```
npm i i18n-chunks-webpack-plugin
```

## Usage

**webpack.config.js**

```js
const I18NChunksWebpackPlugin = require('i18n-chunks-webpack-plugin')

module.exports = {
  entry: 'index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'index_bundle.js'
  },
  plugins: [
    new I18NChunksWebpackPlugin({
      // Modules requiring translation
      modules: [
        {
          // Identigying module
          rule: /src\/module1\.js$/i,

          // Defining langs for it
          languagesFiles: {
            'en-US': '@/i18n/en.js', // Filename doesen't matter but key does.
            'fr-FR': '@/i18n/fr.js'
          }
        },
        // ... you can add other rules or import a ones of package
      ],

      /**
       * Directory for temporary files (i18n chunks)
       **/
      tmpEntriesPath: './webpack-i18n-entries'
    })
  ]
}
```

## Results

The plugin will generate i18n chunks next to the code chunks:

| Filename| Description |
| --- | --- |
| *Code chunks:* |
| app.js | Main app chunk |
| 0.js | Lazy loaded chunk |
| 1.js | Lazy loaded chunk |
| index.html | App html |
| *I18N Chunks:* |
| app-en-US.js | App english chunk |
| app-fr-FR.js | App french chunk |
| 0-en-US.js | Lazy loaded I18N chunk |
| 0-fr-FR.js | Lazy loaded I18N chunk |
| 1-en-US.js | Lazy loaded I18N chunk |
| 1-fr-FR.js | Lazy loaded I18N chunk |
| webpack-i18n-manifest.js | I18N Chunk manifest |

The app chunk is necessary if the user wants to change the language of the page.
Each I18N chunk will contains translation for all files in the associated chunk.
I will publish a project to import and use these i18n chunks on the client side and update this doc later.
Stay tuned!

---
_Source: https://npm.io/package/i18n-chunks-webpack-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
