0.0.1 • Published 1 year ago

auto-internationalize v0.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

auto-internationalize 自动国际化插件

项目

npm run build 执行打包命令 npm publish 发布 npm

介绍

自动翻译 react 项目中的中文

安装

npm i auto-internationalize -D

使用

webpack

const { AutoInternationalize } = require("auto-internationalize/webpack");

module.exports = {
  webpack: {
    plugins: [
      new AutoInternationalize({
        locale: "US",
        fallback: "CN",
        npId: 0,
        env: "production",
        enableMissingReport: true,
        enableUsedReport: true,
        projectName: "CCC",
        storage: {
          key: "cmp_lang",
          type: "localStorage",
        },
      }),
    ],
  },
};

vite

import react from "@vitejs/plugin-react";
import { AutoInternationalize } from "auto-internationalize/vite";

export default defineConfig({
  plugins: [
    AutoInternationalize({
      // 需要在 react 插件前
      locale: "US",
      fallback: "CN",
      npId: 0,
      env: "production",
      enableMissingReport: true,
      enableUsedReport: true,
      projectName: "CCC",
      storage: {
        key: "cmp_lang",
        type: "localStorage",
      },
    }),
    react(),
  ],
});