# mini-locales-extract-plugin

> This plugin extracts Locales with Chinese into separate files. It creates a locales file which contains JSON.

Latest version **0.1.0** (published 2021-09-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install mini-locales-extract-plugin
pnpm add mini-locales-extract-plugin
yarn add mini-locales-extract-plugin
bun add mini-locales-extract-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.0 |
| Published | 2021-09-22 |
| First published | 2021-08-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 30 |
| Unpacked size | 36.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | 刘泽锦 |
| Maintainers | best_liuzejin |

## Links

- npm: https://www.npmjs.com/package/mini-locales-extract-plugin
- Repository: https://github.com/MR-liu/MINI-LOCALES-EXTRACT-PLUGIN
- Homepage: https://github.com/MR-liu/MINI-LOCALES-EXTRACT-PLUGIN#readme
- Issues: https://github.com/MR-liu/MINI-LOCALES-EXTRACT-PLUGIN/issues
- npm.io page: https://npm.io/package/mini-locales-extract-plugin

## Dependencies (30)

- [jsx](https://npm.io/package/jsx.md) ^0.9.89
- [ora](https://npm.io/package/ora.md) ^5.4.1
- [flow](https://npm.io/package/flow.md) ^0.2.3
- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [chalk](https://npm.io/package/chalk.md) ^4.1.1
- [clear](https://npm.io/package/clear.md) ^0.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [babylon](https://npm.io/package/babylon.md) ^6.18.0
- [@babel/cli](https://npm.io/package/@babel/cli.md) ^7.14.5
- [typescript](https://npm.io/package/typescript.md) ^4.3.2
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.14.6
- [@babel/parser](https://npm.io/package/@babel/parser.md) ^7.14.4
- [@babel/traverse](https://npm.io/package/@babel/traverse.md) ^7.14.5
- [@babel/generator](https://npm.io/package/@babel/generator.md) ^7.14.5
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.15.0
- [@babel/preset-react](https://npm.io/package/@babel/preset-react.md) ^7.14.5
- [@babel/plugin-syntax-jsx](https://npm.io/package/@babel/plugin-syntax-jsx.md) ^7.14.5
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.15.0
- [@babel/plugin-syntax-flow](https://npm.io/package/@babel/plugin-syntax-flow.md) ^7.14.5
- [@babel/plugin-syntax-typescript](https://npm.io/package/@babel/plugin-syntax-typescript.md) ^7.14.5
- [@babel/plugin-proposal-decorators](https://npm.io/package/@babel/plugin-proposal-decorators.md) ^7.14.5
- [@babel/plugin-syntax-function-bind](https://npm.io/package/@babel/plugin-syntax-function-bind.md) ^7.14.5
- [@babel/plugin-syntax-function-sent](https://npm.io/package/@babel/plugin-syntax-function-sent.md) ^7.14.5
- [@babel/plugin-transform-typescript](https://npm.io/package/@babel/plugin-transform-typescript.md) ^7.14.4
- [@babel/plugin-syntax-do-expressions](https://npm.io/package/@babel/plugin-syntax-do-expressions.md) ^7.14.5
- [@babel/plugin-syntax-dynamic-import](https://npm.io/package/@babel/plugin-syntax-dynamic-import.md) ^7.8.3
- [@babel/plugin-syntax-async-generators](https://npm.io/package/@babel/plugin-syntax-async-generators.md) ^7.8.4
- [@babel/plugin-syntax-class-properties](https://npm.io/package/@babel/plugin-syntax-class-properties.md) ^7.12.13
- [@babel/plugin-syntax-export-extensions](https://npm.io/package/@babel/plugin-syntax-export-extensions.md) ^7.0.0-beta.32
- [@babel/plugin-syntax-object-rest-spread](https://npm.io/package/@babel/plugin-syntax-object-rest-spread.md) ^7.8.3

## Recent versions

- 0.1.0 (latest) — 2021-09-22
- 0.0.4 — 2021-09-22
- 0.0.3 — 2021-08-06
- 0.0.2 — 2021-08-05
- 0.0.1 — 2021-08-05

## README

# MINI-LOCALES-EXTRACT-PLUGIN

This plugin extracts Locales with Chinese into separate files. It creates a locales file which contains JSON. 

It builds on top of a new webpack v4 feature (module types) and requires webpack 4 to work.

## Getting Started

To begin, you'll need to install `mini-locales-extract-plugin`:

```bash
npm install --save-dev mini-locales-extract-plugin
```

Then add the loader and the plugin to your `webpack` config. For example:

**webpack.config.js**

```
    const MiniCssExtractPlugin = require('mini-css-extract-plugin');
```

```
...
 module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: [
          {
            loader: MiniLocalesExtractPlugin.loader,
            options: {
              extractName: 't',
              cachePath: '/',
              output: 'locales',
              localesName: 'Zn-ch',
              common: true,
              filter: (name) => {
                if (!name) return "";
                let t = name.replace("common", "cm");
                t = t.replace("components", "com");
                t = t.replace("containers", "ct");
                t = t.replace(".service", "");
                t = t.replace(".index", "");
                t = t.toLowerCase();
                return t;
              }
            }
          },
        ]
    }
    
...
```

```
...

plugins: [
    new MiniLocalesExtractPlugin(),
  ],
.
..
```

### Plugin Options

| Name | Type | Default | Description  |
| :


Name | Type | Default | Description
---|--- | --- | ---
extractName | String | t |
cachePath | String | /:cwd/node_modules/.cache/ |
output | String | /:locales |
localesName | String | zh-cn |
common | Boolean | false |
filter | Function | () => {} |

#### `extractName`

Type: `String`
Default: `t`

> i18n_function name

#### `cachePath`

Type: `String`
Default: `/:cwd/node_modules/.cache/`

> cache path

#### `output`

Type: `String`
Default: `/:locales`

> locales path 

#### `localesName`

Type: `String`
Default: `zh-cn`

> locales file name 

#### `common`

Type: `Boolean`
Default: `false`

> use compare multiple projects

#### `filter`

Type: `String`
Default: `zh-cn`

> Used to filter keywords. The formal parameter is the currently extracted `keyname`

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