Skip to content

Commit

Permalink
chore: add formatjs extract & compile scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
visiky committed Mar 14, 2023
1 parent af4d236 commit 2895b25
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 163 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ public

# package lock file
package-lock.json

# temp
**temp**
11 changes: 11 additions & 0 deletions i18n.formatter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
exports.format = function (msgs) {
const results = {};
for (const [id, msg] of Object.entries(msgs)) {
// results[id] = {
// string: msg.defaultMessage,
// comment: msg.description,
// };
results[id] = msg.defaultMessage || msg.description || id;
}
return results;
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"prepare": "husky install",
"lint-staged": "lint-staged",
"i18n-pick": "node ./scripts/i18n-pick.js",
"extract": "formatjs extract 'src/**/*.ts*' --ignore '**/locales/**' --out-file temp.json --flatten",
"compile": "formatjs compile 'temp.json' --out-file i18n/en.json && rm temp.json",
"extract": "formatjs extract 'src/**/*.ts*' --ignore '**/locales/**' --format i18n.formatter.js --out-file i18n.temp.json --flatten",
"compile": "formatjs compile 'temp.json' --out-file i18n/en.json && rm i18n.temp.json",
"extract-compile": "npm run extract && npm run compile"
},
"lint-staged": {
Expand Down
6 changes: 2 additions & 4 deletions src/components/Resume/Template1/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const Template1: React.FC<Props> = props => {
<b>{education.school}</b>
<span className="sub-info" style={{ float: 'right' }}>
{start}
{end ? ` ~ ${end}` : ` $<FormattedMessage id="至今" />`}
{end ? ` ~ ${end}` : <FormattedMessage id=" 至今" />}
</span>
</div>
<div>
Expand Down Expand Up @@ -313,9 +313,7 @@ export const Template1: React.FC<Props> = props => {
</b>
<span className="info-time">
{start}
{end
? ` ~ ${end}`
: ` $<FormattedMessage id="至今" />`}
{end ? ` ~ ${end}` : <FormattedMessage id=" 至今" />}
</span>
</div>
<div className="work-description">{work.work_desc}</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Resume/Template2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export const Template2: React.FC<Props> = props => {
</b>
<span className="info-time">
{start}
{end ? ` ~ ${end}` : ` $<FormattedMessage id="至今" />`}
{end ? ` ~ ${end}` : <FormattedMessage id=" 至今" />}
</span>
</div>
<div className="work-description">{work.work_desc}</div>
Expand Down
6 changes: 2 additions & 4 deletions src/components/Resume/Template3/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export const Template3: React.FC<Props> = props => {
</span>
<span className="sub-info" style={{ float: 'right' }}>
{start}
{end ? ` ~ ${end}` : ` $<FormattedMessage id="至今" />`}
{end ? ` ~ ${end}` : <FormattedMessage id=" 至今" />}
</span>
</div>
</div>
Expand Down Expand Up @@ -312,9 +312,7 @@ export const Template3: React.FC<Props> = props => {
</b>
<span className="info-time">
{start}
{end
? ` ~ ${end}`
: ` $<FormattedMessage id="至今" />`}
{end ? ` ~ ${end}` : <FormattedMessage id=" 至今" />}
</span>
</div>
<div className="work-description">{work.work_desc}</div>
Expand Down
88 changes: 88 additions & 0 deletions src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"locale": "en-US",

"预览": "Preview",
"编辑": "Edit",

"已缓存在本地": "Save to localStorage",

"导入配置": "Import config",
"复制配置": "Copy config",
"保存简历": "Save Resume",
"下载 PDF": "Download pdf",
"进行配置": "Enter config",
"选择模板": "Choose template",
"配置简历": "Config resume",
"确认删除": "Confirm delete",
"继续添加": "Continue add",
"提交": "Submit",
"主题色": "Brand color",
"Tag 标签色": "Tag color",

"工作经验": "Work experience",
"自我介绍": "Introduction",
"教育背景": "Educational background",
"个人作品": "Personal works",
"专业技能": "Professional skills",
"更多信息": "More information",
"工作经历": "Work experience",
"项目经历": "Project experience",
"项目描述": "Description",
"主要工作": "Main work",
"至今": "to present",
"访问链接": "link",

"头像设置": "Avatar",
"个人信息": "Personal information",
"个人技能": "Personal skills",

"隐藏头像": "Hide avatar",
"姓名": "Fullname",
"手机号码": "Mobile",
"邮箱": "Email",
"知乎": "Zhihu",
"职位": "Position title",
"期望工作地": "work space",
"起始时间": "Start time",
"学校": "School",
"专业": "Major in",
"项目名称": "Project name",
"担任角色": "Project role",
"部门": "Apartment",
"公司名称": "Compare name",
"职位或描述": "职位或描述",
"作品名称": "Work name",
"作品链接": "Work link",
"作品描述": "Work description",
"技能项": "Skill",
"技能描述": "Skill description",
"掌握程度": "Degree of mastery",
"奖项内容": "Awards description",
"获奖时间": "Awards time",

"默认模板(适用于单页)": "Default template, apply to single page",
"简易模板": "Simple template",
"简易模板(适用于多页)": "Simple template, apply to multiple page",

"移动端模式下,只支持预览,不支持配置": "",
"移动端只提供查看功能,在线制作请前往 PC 端": "",
"上传配置已应用": "上传配置已应用",
"上传文件有误,请重新上传": "",
"您当前浏览器不支持 FileReader,建议使用谷歌浏览器": "",
"编辑模式下, 切换国际化会导致配置内容丢失,请及时保存": "",
"进入在线编辑": "进入在线编辑",
"获取简历信息失败": "获取简历信息失败",
"确定": "Ok",

"无用户信息模式下,不允许预览": "",
"Github": "Github",
"从模板中获取": "Get from template",
"参考:": "参考:",
"头像形状": "头像形状",
"圆形": "圆形",
"方形": "方形",
"无用户信息,不允许预览": "无用户信息,不允许预览",
"编辑之后,请及时存储个人信息到个人仓库中。": "编辑之后,请及时存储个人信息到个人仓库中。",
"编辑模式下, 切换国际化会导致正在配置的内容丢失,请及时保存": "编辑模式下, 切换国际化会导致正在配置的内容丢失,请及时保存",
"起止时间": "起止时间"
}
80 changes: 0 additions & 80 deletions src/i18n/locales/en-US.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import qs from 'query-string';
import Header from '@/layout/header';
import Footer from '@/layout/footer';
import Content from '@/components';
import { EN_US_LOCALE } from '@/i18n/locales/en-US';
import EN_US_LOCALE from '@/i18n/locales/en-US.json';
import { getLanguage, registerLocale, getLocale } from '@/i18n';
import { IntlProvider } from 'react-intl';
import './index.less';
Expand Down
71 changes: 0 additions & 71 deletions temp.json

This file was deleted.

0 comments on commit 2895b25

Please sign in to comment.