Commit f1da992f authored by dragondean@qq.com's avatar dragondean@qq.com

collectI18nMessages.js用语提取src目录下需要翻译的内容

parent fa4510dc
......@@ -9,7 +9,8 @@ yarn-error.log*
tests/**/coverage/
tests/e2e/reports
selenium-debug.log
# 提取的需要翻译的文件列表
messages.txt
# Editor directories and files
.idea
.vscode
......
const fs = require('fs');
const root = "./src"
let allFiles = []
function getFiles(dir){
let files = fs.readdirSync(dir)
files.forEach(file => {
let path = dir + '/' + file
if(fs.lstatSync(path).isDirectory()){
getFiles(path)
}else allFiles.push(path)
})
}
getFiles(root)
let messages = new Set()
allFiles.forEach(file => {
let data = fs.readFileSync(file, {encoding: 'utf-8'})
let matched = data.matchAll(/\$t\([\'\"]{1}([^\"\']+)[\'\"]{1}\)/g)
let i = 0
for(let item of matched){
i ++
messages.add(item[1])
}
})
fs.writeFileSync("./messages.txt", Array.from(messages).join("\n"))
console.log("done!")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment