0.0.6 • Published 2 years ago

ehr-i18n-plugin v0.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

ehr-i18n-plugin

Install

使用 npm:

npm install --save-dev ehr-i18n-plugin

or using yarn:

yarn add ehr-i18n-plugin --dev

Use

共有两种办法执行 ehr-i18n-plugin

需要转换的文件路径 输出的文件路径是必填的

  1. 利用命令行
  • 执行翻译命令
  ehr-i18n-plugin -e [path] -o [path] -x [path] -l [localeNames]
  • 执行打包成 excel 命令
ehr-i18n-plugin -o [path] -p
  1. 在根目录下新建配置文件 ehr-i18n-plugin.config.js
module.exports = () => ({
  entry: "需要转换的文件路径",
  output: "输出的文件路径",
   //排除的文件(类型是数组) 
  exclude: [],
  //可以自定义随机字符串,第一个参数是当前文件的路径
  randomFuc: (filePath) => `${filePath.split('/').pop()}-${Math.random()}`,
  locales: 'zh_CN,pt_PT,en_US'
  // locales: ['zh_CN', 'pt_PT', 'en_US']
})

已办

  • 替换情况
    • js
      • 对象中的中文字符串
      • 方法中的中文传参
      • 模板字符串(包含简单变量)
    • react
      • react中的中文属性
      • react中的中文内容
    • vue(待补充)
  • excel
    • 翻译词条文件转换为 excel
  • 替换后文件格式化(babel-generator还原的代码格式有很大的问题,由此引入 prettier 对生成的代码进行格式化)