Giter VIP home page Giter VIP logo

i18n-ast's Introduction

i18n-ast

Install

使用 npm:

npm install --save-dev i18n-ast

or using yarn:

yarn add i18n-ast --dev

Use

共有两种办法执行 i18n-ast

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

  1. 利用命令行
  • 执行翻译命令
  i18n-ast -e [path] -o [path] -x [path] -l [localeNames]
  • 执行打包成 excel 命令
i18n-ast -o [path] -p
  1. 在根目录下新建配置文件 i18n-ast.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']
})

Todo List

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

i18n-ast's People

Contributors

unstone avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.