# webpack-i18n-generate-json

> generate i18n to json file

Latest version **1.3.4** (published 2026-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install webpack-i18n-generate-json
pnpm add webpack-i18n-generate-json
yarn add webpack-i18n-generate-json
bun add webpack-i18n-generate-json
```

Provides the command `i18n-generate`.

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

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

## Facts

| | |
|---|---|
| Version | 1.3.4 |
| Published | 2026-02-12 |
| First published | 2018-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | shine |
| Maintainers | gkshine |
| Keywords | i18n, webpack, translation, generate, json, vue |

## Links

- npm: https://www.npmjs.com/package/webpack-i18n-generate-json
- Repository: git@repo.gokuai.cn:web/webpack-i18n-generate
- npm.io page: https://npm.io/package/webpack-i18n-generate-json

## 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.3.4 (latest) — 2026-02-12
- 1.3.3 — 2026-02-05
- 1.3.2 — 2025-04-18
- 1.3.1 — 2025-04-18
- 1.3.0 — 2025-04-18
- 1.2.2 — 2025-04-18
- 1.2.1 — 2023-09-15
- 1.2.0 — 2023-03-21
- 1.1.8 — 2020-02-17
- 1.1.7 — 2020-01-06
- 1.1.6 — 2020-01-05
- 1.1.5 — 2020-01-05
- 1.1.4 — 2020-01-04
- 1.1.3 — 2020-01-03
- 1.1.2 — 2019-12-26
- … 5 more at https://npm.io/package/webpack-i18n-generate-json/versions

## README

# Generate translation json files for [vue-i18n](https://github.com/kazupon/vue-i18n)

[vue-i18n](https://github.com/kazupon/vue-i18n) is great, but making translation files can be a big manual job! This script will search your app and generate translation json files for you.
It's actually not tied to i18n-webpack-plugin at all. In fact I use it with my own translation function that is called at runtime. For that reason I provide the option to make your keys transformed to snake-case. This is my personal preference.

## Basic Example

### package.json
```
  scripts: {
    "i18n-generate": "i18n-generate -d src -l 'en zh-CN'"
  }
```

### App code
```
  <span>{{$t('oh hi, I need to be translated')}}</span>
  <span>{{$t('this script will save me {number} hours', {number: 73})}}</span> // variable replacement
```

### Output translation json - send it to the translator. Regenerating it won't delete existing translations.
```
  {
    "oh hi, I need to be translated": "!!oh hi, I need to be translated",
    "this script will save me {number} hours": "!!this script will save me {number} hours"
  }  
```

## Install
`npm i webpack-i18n-generate-json --save-dev`

## Run
1. add a script (see example package.json)
2. `npm run i18n-generate`

## Options
- `-d, -directory, REQUIRED, default [none]`
- `-b, -base directory, default [none]`
- `-f, -functionName, default [\\$t]`
- `-o, -outputDirectory, default [lang]`
- `-l, -languages, default ['en']`
- `-t, -transformise, default [false] : Transformises using lower snake case whilst preserving the * character to be used for variable substitution. e.g. the key for $t('i have *number* ducks') is 'i_have_*number*_ducks'`
- `-x, -deleteExpired, default [false] : deletes unused translations`

## Advanced Example using lower-snake-case keys
```
  import { transformise } from 'i18n-generate-json';

  // custom translate function
  export function translate(translations, key) {
    const translation = translations[transformise(key)];
    if (translation) return translation;    
    return key;
  }
```

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