93 lines
2.1 KiB
JavaScript
93 lines
2.1 KiB
JavaScript
import fs from 'fs';
|
|
import _ from 'lodash';
|
|
import {appList, ScopeApp, navList, ScopeRoute, BasicFuncsI18n, ScopeFuncs} from './function.mjs';
|
|
|
|
const i18nFuncZhCn = [];
|
|
const i18nFuncEn = [];
|
|
const i18nAppZhCn = [];
|
|
const i18nAppEn = [];
|
|
const i18nRouteZhCn = [];
|
|
const i18nRouteEn = [];
|
|
|
|
for (const key in BasicFuncsI18n) {
|
|
if (Object.hasOwnProperty.call(BasicFuncsI18n, key)) {
|
|
const element = BasicFuncsI18n[key];
|
|
i18nFuncZhCn.push(`${key}: '${element.zhCn}',`);
|
|
i18nFuncEn.push(`${key}: '${element.en}',`);
|
|
}
|
|
}
|
|
|
|
for (const item of appList) {
|
|
i18nAppZhCn.push(`${item.name}: '${item.zhCn}',`);
|
|
i18nAppEn.push(`${item.name}: '${item.en}',`);
|
|
if (item.pages && item.pages.length > 0) {
|
|
for (const page of item.pages) {
|
|
i18nRouteZhCn.push(`${page.name}: '${page.zhCn}',`);
|
|
i18nRouteEn.push(`${page.name}: '${page.en}',`);
|
|
}
|
|
}
|
|
}
|
|
for (const item of navList) {
|
|
i18nRouteZhCn.push(`${item.name}: '${item.zhCn}',`);
|
|
i18nRouteEn.push(`${item.name}: '${item.en}',`);
|
|
}
|
|
|
|
try {
|
|
fs.writeFileSync(
|
|
`./i18n/en.ts`,
|
|
`export default {
|
|
staticRoutes: {
|
|
index: 'Home',
|
|
login: 'Login',
|
|
authRedirect: 'Auth Redirect',
|
|
signIn: 'Sign In',
|
|
notFound: 'Not Found',
|
|
noPower: 'No Power',
|
|
home: 'Home',
|
|
personal: 'Personal Center',
|
|
invite: 'Invite Record',
|
|
tokenLogin: 'Token Login',
|
|
},
|
|
${ScopeFuncs}: {
|
|
${i18nAppEn.join('\n ')}
|
|
},
|
|
${ScopeApp}: {
|
|
${i18nAppEn.join('\n ')}
|
|
},
|
|
${ScopeRoute}: {
|
|
${i18nRouteEn.join('\n ')}
|
|
},
|
|
};`
|
|
);
|
|
console.log(`file written successfully :>> en.ts\n`);
|
|
fs.writeFileSync(
|
|
`./i18n/zh-cn.ts`,
|
|
`export default {
|
|
staticRoutes: {
|
|
index: '首页',
|
|
login: '登录',
|
|
authRedirect: '回调页',
|
|
signIn: '登录',
|
|
notFound: '找不到此页面',
|
|
noPower: '没有权限',
|
|
home: '首页',
|
|
personal: '个人中心',
|
|
invite: '邀请记录',
|
|
tokenLogin: 'Token登录',
|
|
},
|
|
${ScopeFuncs}: {
|
|
${i18nFuncZhCn.join('\n ')}
|
|
},
|
|
${ScopeApp}: {
|
|
${i18nAppZhCn.join('\n ')}
|
|
},
|
|
${ScopeRoute}: {
|
|
${i18nRouteZhCn.join('\n ')}
|
|
},
|
|
};`
|
|
);
|
|
console.log(`file written successfully :>> zh-cn.ts\n`);
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|