Git Product home page Git Product 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

i18n-ast's Issues

wordList is null

源码collectAndWrite.js
缺少对wordList变量的定义,每次扫描都报错。

有个问题请教下:
现在扫描完后,再次扫描就看不到哪些文件拥有汉字了,只有第一次去扫描或者修改或新增中文后能扫描到文件,我怎么修改能每次都扫描到拥有汉字的文件了。

使用 CLI运行, -c 命令不能使用 error: unknown option `-c'

使用该命令 npx i18n-ast -c i18n-ast.config.js 运行项目,报错: error: unknown option `-c'

执行源码,发现配置文件自定义命名,报错: 预期配置文件不存在
查看源码,发现代码中 const configPath = ${cwdPath}/${programOption.configPath || 'i18n-ast.config.js'}``使用configPath 字段,实际上应该为config

关于是否由于configPath字段原因导致-c 命令行参数报错,没找到依据

@unStone 希望作者大大帮忙看下,谢谢~

匹配VUE

初步思路:
1、获取 vue 源码,将其拆分为 template 、script 、 style 三部分
2、将三部分提取中文并转换
3、将转换后的代码合成一份,写回到原文件

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.