Skip to content

Commit 675c2d0

Browse files
committed
fix: 🐛fix l10n bugs
1 parent a9a663e commit 675c2d0

9 files changed

Lines changed: 79 additions & 34 deletions

File tree

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99

1010
# Emoji Commit
1111

12-
![](https://github.com/hks2002/emoji-commit/raw/master/images/icon.png)
13-
14-
![Version](https://img.shields.io/github/package-json/v/hks2002/emoji-commit)
15-
![Build Status](https://img.shields.io/github/actions/workflow/status/hks2002/emoji-commit/Build.yml)
16-
![GitHub License](https://img.shields.io/github/license/hks2002/emoji-commit)
17-
![GitHub Starts](https://img.shields.io/github/stars/hks2002/emoji-commit)
18-
![downloads](https://img.shields.io/visual-studio-marketplace/d/MerBleueAviation.emoji-commit)
19-
![installs](https://img.shields.io/visual-studio-marketplace/i/MerBleueAviation.emoji-commit)
20-
![rating](https://img.shields.io/visual-studio-marketplace/r/MerBleueAviation.emoji-commit)
12+
![](https://github.com/hks2002/emoji-commit-tiny/raw/master/images/icon.png)
13+
14+
![Version](https://img.shields.io/github/package-json/v/hks2002/emoji-commit-tiny)
15+
![Build Status](https://img.shields.io/github/actions/workflow/status/hks2002/emoji-commit-tiny/Build.yml)
16+
![GitHub License](https://img.shields.io/github/license/hks2002/emoji-commit-tiny)
17+
![GitHub Starts](https://img.shields.io/github/stars/hks2002/emoji-commit-tiny)
18+
![downloads](https://img.shields.io/visual-studio-marketplace/d/MerBleueAviation.emoji-commit-tiny)
19+
![installs](https://img.shields.io/visual-studio-marketplace/i/MerBleueAviation.emoji-commit-tiny)
20+
![rating](https://img.shields.io/visual-studio-marketplace/r/MerBleueAviation.emoji-commit-tiny)
2121
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
2222

2323
[English](./README.md) | [简体中文](./README.zh-cn.md)
2424

25-
![ui](https://github.com/hks2002/emoji-commit/raw/master/images/ui.png)
25+
![ui](https://github.com/hks2002/emoji-commit-tiny/raw/master/images/ui.png)
2626

2727
Allowed you to customize the emoji icon, change it to your favorite icon.
2828

29-
![ui](https://github.com/hks2002/emoji-commit/raw/master/images/setting.png)
29+
![ui](https://github.com/hks2002/emoji-commit-tiny/raw/master/images/setting.png)
3030

3131
**Enjoy!**

README.zh-cn.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99

1010
# Emoji Commit
1111

12-
![](https://github.com/hks2002/emoji-commit/raw/master/images/icon.png)
13-
14-
![Version](https://img.shields.io/github/package-json/v/hks2002/emoji-commit)
15-
![Build Status](https://img.shields.io/github/actions/workflow/status/hks2002/emoji-commit/Build.yml)
16-
![GitHub License](https://img.shields.io/github/license/hks2002/emoji-commit)
17-
![GitHub Starts](https://img.shields.io/github/stars/hks2002/emoji-commit)
18-
![downloads](https://img.shields.io/visual-studio-marketplace/d/MerBleueAviation.emoji-commit)
19-
![installs](https://img.shields.io/visual-studio-marketplace/i/MerBleueAviation.emoji-commit)
20-
![rating](https://img.shields.io/visual-studio-marketplace/r/MerBleueAviation.emoji-commit)
12+
![](https://github.com/hks2002/emoji-commit-tiny/raw/master/images/icon.png)
13+
14+
![Version](https://img.shields.io/github/package-json/v/hks2002/emoji-commit-tiny)
15+
![Build Status](https://img.shields.io/github/actions/workflow/status/hks2002/emoji-commit-tiny/Build.yml)
16+
![GitHub License](https://img.shields.io/github/license/hks2002/emoji-commit-tiny)
17+
![GitHub Starts](https://img.shields.io/github/stars/hks2002/emoji-commit-tiny)
18+
![downloads](https://img.shields.io/visual-studio-marketplace/d/MerBleueAviation.emoji-commit-tiny)
19+
![installs](https://img.shields.io/visual-studio-marketplace/i/MerBleueAviation.emoji-commit-tiny)
20+
![rating](https://img.shields.io/visual-studio-marketplace/r/MerBleueAviation.emoji-commit-tiny)
2121
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
2222

2323
[English](./README.md) | [简体中文](./README.zh-cn.md)
2424

25-
![ui](https://github.com/hks2002/emoji-commit/raw/master/images/ui.zh-cn.png)
25+
![ui](https://github.com/hks2002/emoji-commit-tiny/raw/master/images/ui.zh-cn.png)
2626

2727
可以自行修改 emoji 图标
2828

29-
![ui](https://github.com/hks2002/emoji-commit/raw/master/images/setting.png)
29+
![ui](https://github.com/hks2002/emoji-commit-tiny/raw/master/images/setting.png)
3030

3131
**欢迎使用!**

images/icon.png

2.02 KB
Loading

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
},
2525
"dependencies": {
2626
"@types/lodash": "^4.14.177",
27-
"dayjs": "^1.10.7"
27+
"dayjs": "^1.10.7",
28+
"i18next": "^22.4.9"
2829
},
2930
"comment": "[prettier,eslint-plugin-prettier,eslint-config-prettier][husky,semantic-release,@commitlint/config-conventional,@semantic-release/changelog,@semantic-release/git]",
3031
"devDependencies": {
@@ -41,12 +42,12 @@
4142
"@vscode/test-electron": "^2.2.0",
4243
"@vscode/vsce": "2.17.0",
4344
"eslint": "^8.28.0",
45+
"eslint-config-prettier": "^8.6.0",
46+
"eslint-plugin-prettier": "4.2.1",
4447
"glob": "^8.0.3",
4548
"husky": "^8.0.2",
4649
"mocha": "^10.1.0",
4750
"prettier": "^2.5.1",
48-
"eslint-plugin-prettier": "4.2.1",
49-
"eslint-config-prettier": "^8.6.0",
5051
"semantic-release": "^20.1.0",
5152
"ts-loader": "^9.4.1",
5253
"typescript": "^4.9.3",
@@ -168,7 +169,7 @@
168169
}
169170
},
170171
"additionalProperties": false,
171-
"markdownDescription": "%git-commit-lint-vscode.emojis%"
172+
"markdownDescription": "%emoji-commit-tiny.emojis%"
172173
},
173174
"emoji-commit-tiny.additionalType": {
174175
"order": 4,

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"emojis": "Emojis",
23
"emoji-commit.emojiPosition": "Emoji Position in commit message",
34
"emoji-commit.additionalTypes": "Additional types, if enabled commitlint, you must add them to it's rules."
45
}

package.nls.zh-cn.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"emojis": "Emoji表情",
23
"emoji-commit.emojiPosition": "Emoji 在提交信息中的位置",
34
"emoji-commit.additionalTypes": "额外的提交类型, 如果启用了commitlint, 需要将新增的type加入到rule中"
45
}

src/extension.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,48 @@
22
* @Author : Robert Huang<56649783@qq.com> *
33
* @CreatedDate : 2023-02-04 10:01:21 *
44
* @LastEditors : Robert Huang<56649783@qq.com> *
5-
* @LastEditDate : 2023-02-05 18:48:28 *
5+
* @LastEditDate : 2023-02-05 23:16:41 *
66
* @FilePath : emoji-commit/src/extension.ts *
77
* @CopyRight : MerBleueAviation *
88
*****************************************************************************/
99

1010
// The module 'vscode' contains the VS Code extensibility API
1111
// Import the module and reference it with the alias vscode in your code below
12+
import i18next from 'i18next'
1213
import * as vscode from 'vscode'
14+
import l10nEn from '../l10n/bundle.l10n.json'
15+
import l10nZh from '../l10n/bundle.l10n.zh-cn.json'
1316
import packageJson from '../package.json'
1417
import { Logger } from './logger'
1518
import { emojiCommit } from './utils'
1619

1720
const config = vscode.workspace.getConfiguration(packageJson.name)
18-
console.debug(config)
21+
// console.debug(config)
1922

2023
const logger = new Logger()
2124
logger.setOutputLevel(config.get('logLevel', 'INFO'))
2225

23-
export { config, logger }
26+
// i18next
27+
const i18nResources = {
28+
en: {
29+
translation: l10nEn
30+
},
31+
// eslint-disable-next-line @typescript-eslint/naming-convention
32+
'zhcn': {
33+
translation: l10nZh
34+
}
35+
}
36+
37+
// lang can't be zh-cn, it should be zhcn
38+
const locale = vscode.env.language.replace('-', '')
39+
logger.info(`locale: ${locale}`)
40+
i18next.init({
41+
lng: locale,
42+
fallbackLng: 'en',
43+
resources: i18nResources
44+
})
45+
46+
export { config, logger, i18next }
2447

2548
// This method is called when your extension is activated
2649
// Your extension is activated the very first time the command is executed

src/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
* @Author : Robert Huang<56649783@qq.com> *
33
* @CreatedDate : 2023-02-05 18:48:09 *
44
* @LastEditors : Robert Huang<56649783@qq.com> *
5-
* @LastEditDate : 2023-02-05 18:48:09 *
5+
* @LastEditDate : 2023-02-05 22:55:03 *
66
* @FilePath : emoji-commit/src/utils.ts *
77
* @CopyRight : MerBleueAviation *
88
*****************************************************************************/
99

1010
/* eslint-disable @typescript-eslint/no-explicit-any */
11+
import i18next from 'i18next'
1112
import * as vscode from 'vscode'
1213
import { CommitEmoji, Obj } from '.'
1314
import packageJson from '../package.json'
1415
import { GitExtension } from './git'
15-
const t = vscode.l10n.t
1616

1717
// 点击小图标进入插件
1818
const getGitExtension = () => {
@@ -41,7 +41,7 @@ const genInput = (type: string, emoji: string, pos: string, message?: string) =>
4141
const emojiCommit = (uri?: { rootUri: { path: any } }) => {
4242
const git = getGitExtension()
4343
if (!git) {
44-
vscode.window.showErrorMessage(t("Can't load git extention, please install it!"))
44+
vscode.window.showErrorMessage(i18next.t("Can't load git extention, please install it!"))
4545
return
4646
}
4747

@@ -53,8 +53,8 @@ const emojiCommit = (uri?: { rootUri: { path: any } }) => {
5353
const position = config.get('position', 'suffix')
5454

5555
for (const key in emojiPreset) {
56-
const label = `${emojiPreset[key]} ${key} ${t(key + '.description')}`
57-
const description = `[${t(key + '.title')}]`
56+
const label = `${emojiPreset[key]} ${key} ${i18next.t(key + '.description')}`
57+
const description = `[${i18next.t(key + '.title')}]`
5858

5959
commitsOptions.push({
6060
type: key,

yarn.lock

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
chalk "^2.0.0"
2424
js-tokens "^4.0.0"
2525

26+
"@babel/runtime@^7.20.6":
27+
version "7.20.13"
28+
resolved "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.20.13.tgz#7055ab8a7cff2b8f6058bf6ae45ff84ad2aded4b"
29+
integrity sha512-gt3PKXs0DBoL9xCvOIIZ2NEqAGZqHjAnmVbfQtB620V0uReIQutpel14KcneZuer7UioY8ALKZ7iocavvzTNFA==
30+
dependencies:
31+
regenerator-runtime "^0.13.11"
32+
2633
"@colors/colors@1.5.0":
2734
version "1.5.0"
2835
resolved "https://registry.npmmirror.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9"
@@ -2762,6 +2769,13 @@ husky@^8.0.2:
27622769
resolved "https://registry.npmmirror.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184"
27632770
integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==
27642771

2772+
i18next@^22.4.9:
2773+
version "22.4.9"
2774+
resolved "https://registry.npmmirror.com/i18next/-/i18next-22.4.9.tgz#98c8384c6bd41ff937da98b1e809ba03d3b41053"
2775+
integrity sha512-8gWMmUz460KJDQp/ob3MNUX84cVuDRY9PLFPnV8d+Qezz/6dkjxwOaH70xjrCNDO+JrUL25iXfAIN9wUkInNZw==
2776+
dependencies:
2777+
"@babel/runtime" "^7.20.6"
2778+
27652779
iconv-lite@^0.6.2:
27662780
version "0.6.3"
27672781
resolved "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501"
@@ -4627,6 +4641,11 @@ redeyed@~2.1.0:
46274641
dependencies:
46284642
esprima "~4.0.0"
46294643

4644+
regenerator-runtime@^0.13.11:
4645+
version "0.13.11"
4646+
resolved "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9"
4647+
integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==
4648+
46304649
regexpp@^3.2.0:
46314650
version "3.2.0"
46324651
resolved "https://registry.npmmirror.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"

0 commit comments

Comments
 (0)