mini-locales-extract-plugin

0.1.0 • Public • Published

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:

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

Readme

Keywords

none

Package Sidebar

Install

npm i mini-locales-extract-plugin

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

37.5 kB

Total Files

14

Last publish

Collaborators

  • best_liuzejin