Skip to content

Commit ec4dea4

Browse files
authored
chore: rewrite some logs message and add not-chinese-message commit rule (#2542)
* chore: use English as the default language in the code * chore: add not-chinese-message rules * chore: use unicode * chore: fix build
1 parent 95c83d5 commit ec4dea4

File tree

32 files changed

+107
-88
lines changed

32 files changed

+107
-88
lines changed

commitlint.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'not-chinese-message-rule': [2, 'always'],
5+
},
6+
plugins: [
7+
{
8+
rules: {
9+
'not-chinese-message-rule': ({ subject }) => {
10+
const regex = /[\u4e00-\u9fa5]+/;
11+
return [!regex.test(subject), 'Please use english to rewrite your commit message'];
12+
},
13+
},
14+
},
15+
],
16+
};

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@
7676
"path": "node_modules/cz-conventional-changelog"
7777
}
7878
},
79-
"commitlint": {
80-
"extends": [
81-
"@commitlint/config-conventional"
82-
]
83-
},
8479
"repository": {
8580
"type": "git",
8681
"url": "[email protected]:opensumi/core.git"

packages/comments/__test__/browser/comment.service.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('comment service test', () => {
8686
const [thread] = createTestThreads(uri);
8787
expect(thread.uri.isEqual(uri));
8888
expect(thread.range.startLineNumber).toBe(1);
89-
expect(thread.comments[0].body).toBe('评论内容1');
89+
expect(thread.comments[0].body).toBe('评论内容');
9090
});
9191

9292
it('get commentsThreads', () => {
@@ -152,7 +152,7 @@ describe('comment service test', () => {
152152
author: {
153153
name: 'User',
154154
},
155-
body: '评论内容1',
155+
body: '评论内容',
156156
},
157157
],
158158
});
@@ -171,7 +171,7 @@ describe('comment service test', () => {
171171
author: {
172172
name: 'User',
173173
},
174-
body: '评论内容1',
174+
body: '评论内容',
175175
},
176176
],
177177
});
@@ -245,7 +245,7 @@ describe('comment service test', () => {
245245
author: {
246246
name: 'User',
247247
},
248-
body: '评论内容1',
248+
body: '评论内容',
249249
},
250250
],
251251
}),

packages/core-browser/src/react-providers/slot.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function getSlotLocation(moduleName: string, layoutConfig: LayoutConfig)
3939
return location;
4040
}
4141
}
42-
getDebugLogger().warn(`没有找到${moduleName}所对应的位置!`);
42+
logger.warn(`Cannot find the location with ${moduleName}`);
4343
return '';
4444
}
4545

@@ -97,14 +97,14 @@ export class ErrorBoundary extends React.Component {
9797
export const allSlot: { slot: string; dom: HTMLElement }[] = [];
9898

9999
export const SlotDecorator: React.FC<{ slot: string; backgroundColor?: string }> = ({ slot, ...props }) => {
100-
const ref = React.useRef<HTMLElement>();
100+
const ref = React.useRef<HTMLElement | null>();
101101
React.useEffect(() => {
102102
if (ref.current) {
103103
allSlot.push({ slot, dom: ref.current });
104104
}
105105
}, [ref]);
106106
return (
107-
<div ref={(ele) => (ref.current = ele!)} className='resize-wrapper'>
107+
<div ref={(ele) => (ref.current = ele)} className='resize-wrapper'>
108108
{props.children}
109109
</div>
110110
);
@@ -163,12 +163,13 @@ export class SlotRendererRegistry {
163163
export const slotRendererRegistry = new SlotRendererRegistry();
164164

165165
export interface SlotProps {
166+
// Name of the slot view
166167
slot: string;
167-
/**
168-
* slot 默认的背景色
169-
*/
168+
// Background color of the slot view
170169
backgroundColor?: string;
170+
// Is tabbar slot renderer or not
171171
isTabbar?: boolean;
172+
// Optional props
172173
[key: string]: any;
173174
}
174175

@@ -181,15 +182,15 @@ export function SlotRenderer({ slot, isTabbar, ...props }: SlotProps) {
181182
slotRendererRegistry.addTabbar(slot);
182183
}
183184
if (!componentKeys || !componentKeys.length) {
184-
getDebugLogger().warn(`No ${slot} view declared by location.`);
185+
logger.warn(`No ${slot} view declared by location.`);
185186
}
186187
const [componentInfos, setInfos] = React.useState<ComponentRegistryInfo[]>([]);
187188
const updateComponentInfos = React.useCallback(() => {
188189
const infos: ComponentRegistryInfo[] = [];
189190
componentKeys.forEach((token) => {
190191
const info = componentRegistry.getComponentRegistryInfo(token);
191192
if (!info) {
192-
getDebugLogger().warn(`${token} view isn't registered, please check.`);
193+
logger.warn(`${token} view isn't registered, please check.`);
193194
} else {
194195
infos.push(info);
195196
}

packages/core-common/src/di-helper/domain-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function getDomainConstructors(...domains: Domain[]) {
4141
constructorSet.add(constructor);
4242
} else {
4343
// eslint-disable-next-line no-console
44-
console.error(`没有获取到 ${String(domain)} 对应的Constructor!`);
44+
console.error(`Unable to retrieve the Constructor for ${String(domain)}`);
4545
}
4646
}
4747
return Array.from(constructorSet);

packages/core-electron-main/src/bootstrap/api.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ export class ElectronMainApiRegistryImpl implements ElectronMainApiRegistry {
1616
private apis: Map<string, ElectronMainApiProxy> = new Map();
1717

1818
@Autowired(INJECTOR_TOKEN)
19-
injector: Injector;
20-
21-
constructor() {}
19+
private readonly injector: Injector;
2220

2321
registerMainApi(name: string, api: IElectronMainApiProvider): IDisposable {
2422
if (this.apis.has(name)) {
25-
this.apis.get(name)!.dispose();
23+
this.apis.get(name)?.dispose();
2624
}
2725
const proxy = this.injector.get(ElectronMainApiProxy, [name, api]);
28-
getDebugLogger().log('注册Electron Main Api: ' + name);
26+
getDebugLogger().log(`Register Electron Main Api: ${name}`);
2927
this.apis.set(name, proxy);
3028

3129
return {

packages/core-electron-main/src/bootstrap/window.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
175175

176176
async start() {
177177
if (this.isRemote) {
178-
getDebugLogger().log('Remote 模式,停止创建 Server 进程');
178+
getDebugLogger().log('[Remote mode] stop creating Server process');
179179
} else {
180180
this.startNode();
181181
}

packages/editor/src/browser/doc-model/editor-document-model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ export class EditorDocumentModel extends Disposable implements IEditorDocumentMo
401401
this.compareAndSave();
402402
}
403403
});
404-
this.logger.error('文件无法保存,版本和磁盘不一致');
404+
this.logger.error('The file cannot be saved, the version is inconsistent with the disk');
405405
return false;
406406
}
407407
return false;

packages/editor/src/browser/monaco-contrib/tokenizer/textmate.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ export class TextmateService extends WithEventBus implements ITextmateTokenizerS
435435
json = parseWithComments(content);
436436
return json;
437437
} catch (error) {
438-
this.logger.error('语言配置文件解析出错!', content);
438+
this.logger.error(`Language configuration file parsing error, ${error.stack}`);
439439
return;
440440
}
441441
}

packages/editor/src/browser/untitled-resource.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ export class UntitledSchemeResourceProvider extends WithEventBus implements IRes
209209
}
210210
// 询问用户是否保存
211211
const buttons = {
212-
[localize('file.prompt.dontSave', '不保存')]: AskSaveResult.REVERT,
213-
[localize('file.prompt.save', '保存')]: AskSaveResult.SAVE,
214-
[localize('file.prompt.cancel', '取消')]: AskSaveResult.CANCEL,
212+
[localize('file.prompt.dontSave', "Don't Save")]: AskSaveResult.REVERT,
213+
[localize('file.prompt.save', 'Save')]: AskSaveResult.SAVE,
214+
[localize('file.prompt.cancel', 'Cancel')]: AskSaveResult.CANCEL,
215215
};
216216
const selection = await this.dialogService.open(
217217
formatLocalize('saveChangesMessage', resource.name),

0 commit comments

Comments
 (0)