forked from visiky/resume
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
176 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
exclude: ['**/locales/**', '**/datas/**'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"下载 PDF": "下载 PDF", | ||
"\n 在线版本\n ": "\n 在线版本\n ", | ||
"在线版本": "在线版本", | ||
" 项目代码\n ": " 项目代码\n ", | ||
" 项目代码": " 项目代码", | ||
"从模板中获取": "从模板中获取", | ||
"已缓存在本地": "已缓存在本地", | ||
"复制成功": "复制成功", | ||
"头像设置": "头像设置", | ||
"个人信息": "个人信息", | ||
"教育背景": "教育背景", | ||
"自我介绍": "自我介绍", | ||
"更多信息": "更多信息", | ||
"个人作品": "个人作品", | ||
"专业技能": "专业技能", | ||
"工作经历": "工作经历", | ||
"项目经历": "项目经历", | ||
"隐藏头像": "隐藏头像", | ||
"头像形状": "头像形状", | ||
"圆形": "圆形", | ||
"方形": "方形", | ||
"姓名": "姓名", | ||
"手机号码": "手机号码", | ||
"邮箱": "邮箱", | ||
"知乎": "知乎", | ||
"工作经验": "工作经验", | ||
"期望工作地": "期望工作地", | ||
"职位": "职位", | ||
"起始时间": "起始时间", | ||
"学校": "学校", | ||
"专业": "专业", | ||
"起止时间": "起止时间", | ||
"项目名称": "项目名称", | ||
"担任角色": "担任角色", | ||
"项目描述": "项目描述", | ||
"主要工作": "主要工作", | ||
"公司名称": "公司名称", | ||
"部门": "部门", | ||
"职位或描述": "职位或描述", | ||
"作品名称": "作品名称", | ||
"作品描述": "作品描述", | ||
"作品链接": "作品链接", | ||
"技能项": "技能项", | ||
"掌握程度": "掌握程度", | ||
"技能描述": "技能描述", | ||
"获奖时间": "获奖时间", | ||
"奖项内容": "奖项内容", | ||
"获取简历信息失败": "获取简历信息失败", | ||
"\n 请检查用户名 ": "\n 请检查用户名 ", | ||
" 是否正确或者简历信息是否在\n ": " 是否正确或者简历信息是否在\n ", | ||
"下\n ": "下\n ", | ||
"请检查用户名 ": "请检查用户名 ", | ||
" 是否正确或者简历信息是否在": " 是否正确或者简历信息是否在", | ||
"下": "下", | ||
"进入在线编辑": "进入在线编辑", | ||
"移动端只提供查看功能,在线制作请前往 PC 端": "移动端只提供查看功能,在线制作请前往 PC 端", | ||
"上传配置已应用": "上传配置已应用", | ||
"上传文件有误,请重新上传": "上传文件有误,请重新上传", | ||
"您当前浏览器不支持 FileReader,建议使用谷歌浏览器": "您当前浏览器不支持 FileReader,建议使用谷歌浏览器", | ||
"参考:": "参考:", | ||
"复制配置": "复制配置", | ||
"保存简历": "保存简历", | ||
"导入配置": "导入配置", | ||
"PDF 下载": "PDF 下载", | ||
"\n 中\n ": "\n 中\n ", | ||
"中": "中", | ||
"编辑模式下, 切换国际化会导致正在配置的内容丢失,请及时保存": "编辑模式下, 切换国际化会导致正在配置的内容丢失,请及时保存", | ||
"编辑": "编辑", | ||
"无用户信息,不允许预览": "无用户信息,不允许预览", | ||
"预览": "预览", | ||
"提交": "提交", | ||
"至今": "至今", | ||
"访问链接": "访问链接", | ||
"确认删除": "确认删除", | ||
"继续添加": "继续添加", | ||
"进行配置": "进行配置", | ||
"移动端模式下,只支持预览,不支持配置": "移动端模式下,只支持预览,不支持配置", | ||
"选择模板": "选择模板", | ||
"配置简历": "配置简历", | ||
" 至今": " 至今", | ||
"默认模板(适用于单页)": "默认模板(适用于单页)", | ||
"简易模板": "简易模板", | ||
"简易模板(适用于多页)": "简易模板(适用于多页)", | ||
"主题色": "主题色", | ||
"tag 标签色": "tag 标签色" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
const glob = require('glob'); | ||
const { transformFileAsync } = require('@babel/core'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const config = require('../i18n.config.js'); | ||
|
||
const wordSet = new Set(); | ||
|
||
/** unicode cjk 中日韩文 范围 */ | ||
const DOUBLE_BYTE_REGEX = /[\u4E00-\u9FFF]/; | ||
function detectChinese(text) { | ||
if (DOUBLE_BYTE_REGEX.test(text)) { | ||
wordSet.add(text); | ||
} | ||
} | ||
|
||
function scan({ types: t }) { | ||
return { | ||
visitor: { | ||
// 匹配: const text = '中文文案'; new Person('小红') | ||
StringLiteral(path) { | ||
const { node } = path; | ||
detectChinese(node.value); | ||
}, | ||
// 匹配: jsx 文本 & 属性 | ||
JSXText(path) { | ||
detectChinese(path.node.value); | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
const { exclude = [] } = config; | ||
|
||
function run(dir) { | ||
glob(`${dir}/**/*.{js,jsx,ts,tsx}`, { | ||
ignore: exclude.concat('node_modules/**'), | ||
}) | ||
.then(files => { | ||
Promise.all( | ||
files.map(filename => { | ||
// todo 可以匹配一些规则,直接返回 | ||
|
||
return transformFileAsync(filename, { | ||
plugins: [ | ||
// 装饰器插件 | ||
['@babel/plugin-proposal-decorators', { legacy: true }], | ||
scan, | ||
], | ||
presets: [ | ||
[ | ||
'@babel/preset-typescript', | ||
// 强制开启 jsx 解析,否则尖括号可能会被识别为 typescript 的类型断言。如 `var foo = <string>bar;` | ||
{ isTSX: true, allExtensions: true }, | ||
], | ||
['@babel/preset-env', { targets: 'chrome > 58' }], | ||
], | ||
}); | ||
}) | ||
).then(() => { | ||
fs.open(path.resolve('i18n', 'tmp.json'), 'w', (error, file) => { | ||
if (error) return console.error(error); | ||
fs.writeFile( | ||
file, | ||
JSON.stringify(Object.fromEntries(wordSet.entries()), null, 2), | ||
() => {} | ||
); | ||
}); | ||
}); | ||
}) | ||
.catch(err => { | ||
console.error(err); | ||
}); | ||
} | ||
|
||
run('./src'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters