# i18n-json-loader

> i18n json file translate loader module for webpack. Use for 'resx2tsjs'

Latest version **1.0.2** (published 2017-07-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install i18n-json-loader
pnpm add i18n-json-loader
yarn add i18n-json-loader
bun add i18n-json-loader
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2017-07-20 |
| First published | 2017-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.12.0 \|\| >=4.0.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Clay Wang |
| Maintainers | lovejunlic |
| Keywords | translate, loader, json, json-loader, webpack, i18n |

## Links

- npm: https://www.npmjs.com/package/i18n-json-loader
- Repository: https://github.com/ClaytonWang/i18n-json-loader
- Homepage: https://github.com/ClaytonWang/i18n-json-loader#readme
- Issues: https://github.com/ClaytonWang/i18n-json-loader/issues
- npm.io page: https://npm.io/package/i18n-json-loader

## Dependencies (1)

- [loader-utils](https://npm.io/package/loader-utils.md) ^1.1.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.2 (latest) — 2017-07-20
- 1.0.1 — 2017-07-20
- 1.0.0 — 2017-07-20

## README

[npm][npm-url]
[node][node-url]

# i18n-json-loader for Webpack

The `i18n-json-loader` folk from `translate-loader`. This loader can resolve like `color.en-US.json`,`color.zh-CN.json`,
they are not need at folder `**en_US/`,`**zh-CN/`.

## Install

```shell
npm install --save-dev i18n-json-loader
```

## Usage

The `i18n-json-loader` enables you to import/require translation modules that are "aliased"
during runtime to specific files, based on browser's locale.

**helloworld.js**
```js
import labels from "labels_nls.json";

console.debug(`${labels.helloWorld} (${labels.localeName})`);
```

**labels_nls.json**
```json
{
    "localeName": "Default",
    "helloWorld": "Hello World"
}
```

labels_nls.en-GB.json**
```json
{
    "localeName": "English",
    "helloWorld": "Hello World"
}
```

labels_nls.en-US.json**
```json
{
    "localeName": "English US",
    "helloWorld": "Hello World"
}
```

labels_nls.es.json**
```json
{
    "localeName": "Español",
    "helloWorld": "Hola Mundo"
}
```

labels_nls.pt.json**
```json
{
    "localeName": "Português",
    "helloWorld": "Olá Mundo"
}
```

**webpack.config.js**
```js
module.exports = {
    module: {
        rules: [{
            test: /_nls\.json$/,
            use: "i18n-json-loader?locales=en;en-US;es;pt"
        }]
    }
};
```

or

**webpack.config.js**
```js
module.exports = {
    module: {
        rules: [{
            test: /_nls\.json$/,
            use: [
                {
                    loader: "i18n-json-loader",
                    options: {
                        locales: [ "en", "en-US", "es", "pt" ]
                    }
                }
            ]
        }]
    }
};
```

## Maintainers

| [Clay Wang][clay] |

[npm-url]: https://www.npmjs.com/package/i18n-json-loader
[node-url]: https://nodejs.org

[clay]: https://github.com/claytonwang

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