GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - unStone/i18n-ast: https://juejin.im/post/5b9f7976e51d450e9e43fd71

BranchesTags
Open more actions menu

Latest commit

 

History

45 Commits
45 Commits

Folders and files

NameName
Last commit message
Last commit date
.vscode
.vscode
 
 
__tests__
__tests__
 
 
bin
bin
 
 
config
config
 
 
example
example
 
 
src
src
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
i18n-ast.config.js
i18n-ast.config.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
国际化流程图(181011-1).png
国际化流程图(181011-1).png
 
 

Repository files navigation

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 对生成的代码进行格式化)

About

https://juejin.im/post/5b9f7976e51d450e9e43fd71

Resources

Readme
Activity

Stars

61 stars

Watchers

2 watching

Forks

17 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.