整体代码(i18n.js)
const fs = require('fs');
const paths = require('path');
/**
* 写入语言文件
* @param {*} en
*/
function writeFile(en) {
const i18n = 'module.exports = ' + JSON.stringify(en)
fs.writeFileSync(paths.resolve('src/i18n/langs/en_US.js'), i18n)
}
/**
* 读取匹配条件的文件
* @param {*} path
*/
function readFile(path) {
let en = {
}
let i = 0;
// 循环获取要匹配的文件
for (let filePath of path) {
filePath = paths.resolve(filePath)
// 读取文件
fs.readFile(filePath, 'utf-8', (err,data)=>{
if(err) {