Skip to content

Commit 6ad63c4

Browse files
committed
✨ feat(i18n): support on or off emoji
1 parent 560fc6a commit 6ad63c4

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

packages/changelog/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ interface ChangelogConfig {
3131
*/
3232
displayTypes?: CommitTypes[];
3333
/**
34-
* there are two languages types
34+
* whether to include emoji in title
3535
*/
36-
language?: 'en-US' | 'zh-CN';
36+
withEmoji?: boolean;
37+
/**
38+
* title language
39+
*/
40+
titleLanguage?: 'en-US' | 'zh-CN';
3741
/**
3842
* whether to show author
3943
*/

packages/changelog/src/customConfig.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ export interface CustomConfig {
1818
* 是否显示作者
1919
*/
2020
showAuthor?: boolean;
21+
/**
22+
* whether to include emoji in title
23+
*/
24+
withEmoji?: boolean;
25+
/**
26+
* title language
27+
*/
28+
titleLanguage?: 'en-US' | 'zh-CN';
2129
}
2230

2331
const explorer = cosmiconfigSync('changelog');

packages/changelog/src/transformer/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ export default (customConfig: CustomConfig) => (
1515
const issues = [];
1616

1717
commit.notes.forEach((note) => {
18-
note.title = 'BREAKING CHANGES';
18+
note.title = `${
19+
customConfig?.withEmoji === false ? '' : '💥 '
20+
}BREAKING CHANGES`;
21+
1922
discard = false;
2023
});
2124

@@ -28,14 +31,16 @@ export default (customConfig: CustomConfig) => (
2831
if (!displayTypes.includes(<CommitTypes>commit.type) && discard) return;
2932

3033
// 修改 type 标题
31-
commit.type = getDisplayName(commit.type);
34+
commit.type = getDisplayName(commit.type, {
35+
language: customConfig.titleLanguage,
36+
withEmoji: customConfig.withEmoji,
37+
});
3238

39+
/** * 处理 scope ** */
3340
if (commit.scope === '*') {
3441
commit.scope = '';
3542
}
3643

37-
/** * 处理 scope ** */
38-
3944
if (customConfig.displayScopes) {
4045
if (!customConfig.displayScopes?.includes(commit.scope)) return;
4146
}

0 commit comments

Comments
 (0)