i18next-webpack-backend
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

i18next-webpack-backend

Backend JSON loader for webpack applications.

NPM version

Build Status

Dependencies Dev dependencies

Get started

Install i18next-webpack-backend package.

$ npm install i18next-webpack-backend

Add module to your i18n configuration and provide context to load translations from to backend

import i18next from "i18next";
import { WebpackBackend } from "i18next-webpack-backend";
 
const i18n = i18next.use(WebpackBackend).init({
    backend: {
        context: require.context("./path/to/translations", true, /\.json$/, "lazy")
    }
});
 
export default i18n;

If you are using multiload adapder:

import i18next from "i18next";
import { WebpackBackend } from "i18next-webpack-backend";
import BackendAdapter from "i18next-multiload-backend-adapter";
 
const i18n = i18next.use(BackendAdapter).init({
    backend: {
        backend: WebpackBackend,
        backendOption: {
            context: require.context("./path/to/translations", true, /\.json$/, "lazy")
        }
    }
});
 
export default i18n;

Translation file structures

Folder structure

Example translations file structure:

.
└── translations/
    ├── en/
    │   ├── commons.json
    │   ├── validation.json
    │   ├── glosarry.json
    │   └── pages/
    │       ├── login.json
    │       └── register.json
    └── lt/
        ├── commons.json
        ├── validation.json
        ├── glosarry.json
        └── pages/
            ├── login.json
            └── register.json

License

Released under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i i18next-webpack-backend

Weekly Downloads

8

Version

0.1.1

License

MIT

Unpacked Size

9.2 kB

Total Files

7

Last publish

Collaborators

  • reactway-dev