Package Exports
- webpack-i18next-join-loader
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (webpack-i18next-join-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
webpack-i18next-join-loader
Webpack loader to join translation files. For example, it can be used to join i18next files.
About
This plugin provides a way to join (merge) multiple translation files separated by UI components (react, Angular,...) and languages (english, russian, italian,...) into global application or module translation unit files.
It hepls:
- use separate translation files for each separate component at coding phase;
- join translation files for using component into global translation units at bundling phase.
For example, if you have two components A and B, and files hierarchy:
|- src/
|- A/
|- A.js
|- index.js
|- locales/
|- en.locale.json
|- ru.locale.json
|- ge.locale.json
|- B/
|- B.js
|- index.js
|- locales/
|- en.locale.json
|- ru.locale.json
|- public/After bundling you will have:
|- src/
|- A/
|- A.js
|- index.js
|- locales/
|- en.locale.json
|- ru.locale.json
|- ge.locale.json
|- B/
|- B.js
|- index.js
|- locales/
|- en.locale.json
|- ru.locale.json
|- public/
|- index.js
|- locales/
|- en.locale.json
|- ru.locale.json
|- ge.locale.jsonwhere src/A/locales/xx.locale.json and src/B/locales/xx.locale.json will be merged to public/locales/xx.locale.json.
Installation
npm install --save-dev webpack-i18next-join-loaderUsage
const I18NextJoinLoader = require('webpack-i18next-join-loader')
{
...
module: {
rules: [{
test: /\.locale\.(json)$/i,
use: [{
loader: I18NextJoinLoader.loader(),
options: {
outputDir: 'locale/',
recursiveMerge: false,
validation: {
singleRoot: true,
uniqueRootPerOutputFile: true
},
},
}],
}],
}
...
}Options:
outputDir- output directory for joined locale files;recursiveMerge- iftruethen files will be merged recursively;validation.singleRoot- iftruethen loader will validate that each translation file has only single root key;validation.uniqueRootPerOutputFile- iftruethen loader will validate that each root key is used only in one of merging file.
License
MIT (https://github.com/ArsCo/webpack-i18next-join-loader/blob/master/LICENSE)
Copyright
Copyright 2018-2020 Arsen Ibragimov (ars)