Skip to content

Commit

Permalink
Merge pull request #81 from visiky/feat/i18n
Browse files Browse the repository at this point in the history
refactor(i18n): 更新国际化方案
  • Loading branch information
visiky authored Mar 14, 2023
2 parents f421149 + c86e472 commit 3c343c4
Show file tree
Hide file tree
Showing 33 changed files with 1,461 additions and 827 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**
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
| template | 模板 | 默认: template1 |
| branch | 分支名 | 默认: master |
| mode | 模式 | 备注: 默认为‘只读’模式,设置为: `mode=edit` 即可进入编辑模式 |
| lang | 语言 | 默认: zh_CN |
| lang | 语言 | 默认: zh-CN |

## 本地开发(Local develop)

Expand Down
3 changes: 3 additions & 0 deletions i18n.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
exclude: ['**/i18n/**', '**/data/**'],
};
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;
};
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@
"react-dnd-html5-backend": "^14.0.0",
"react-dom": "^17.0.1",
"react-helmet": "^6.1.0",
"react-intl": "^6.2.10",
"react-svg": "^14.1.6"
},
"devDependencies": {
"@babel/core": "^7.21.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-decorators": "^7.21.0",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.0",
"@formatjs/cli": "^6.0.4",
"@types/lodash-es": "^4.17.6",
"@types/react": "^17.0.3",
"babel-plugin-import": "^1.13.3",
Expand All @@ -30,6 +38,7 @@
"gatsby-plugin-less": "^5.2.0",
"gatsby-plugin-pnpm": "^1.2.10",
"gh-pages": "^3.1.0",
"glob": "^9.2.1",
"husky": "^7.0.4",
"less": "^4.1.0",
"lint-staged": "^12.3.5",
Expand All @@ -46,7 +55,9 @@
"clean": "gatsby clean",
"deploy": "npm run clean && gatsby build --prefix-paths && gh-pages -d public",
"prepare": "husky install",
"lint-staged": "lint-staged"
"lint-staged": "lint-staged",
"i18n-pick": "node ./scripts/i18n-pick.js",
"extract": "formatjs extract 'src/**/*.ts*' --ignore '**/locales/**' --format i18n.formatter.js --out-file i18n.temp.json --flatten"
},
"lint-staged": {
"*.{ts,tsx}": [
Expand Down
Loading

0 comments on commit 3c343c4

Please sign in to comment.