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

+16
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

-5
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

+4-4
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

+9-8
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

+1-1
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

+3-5
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

+1-1
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

+1-1
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

+1-1
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

+3-3
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),

packages/editor/src/browser/workbench-editor.service.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,9 @@ export class WorkbenchEditorServiceImpl extends WithEventBus implements Workbenc
518518

519519
// 询问用户是否保存
520520
const buttons = {
521-
[localize('file.prompt.dontSave', '不保存')]: AskSaveResult.REVERT,
522-
[localize('file.prompt.save', '保存')]: AskSaveResult.SAVE,
523-
[localize('file.prompt.cancel', '取消')]: AskSaveResult.CANCEL,
521+
[localize('file.prompt.dontSave', "Don't Save")]: AskSaveResult.REVERT,
522+
[localize('file.prompt.save', 'Save')]: AskSaveResult.SAVE,
523+
[localize('file.prompt.cancel', 'Cancel')]: AskSaveResult.CANCEL,
524524
};
525525
const files = toClose.slice(0, MAX_CONFIRM_RESOURCES);
526526
let filesDetail = files.map((v) => v.resource.name).join('、');

packages/express-file-server/__tests__/browser/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('packages/express-file-server/__tests__/browser/index.test.ts', () => {
2121
createContributionProvider(injector, StaticResourceContribution);
2222
// 手动执行 staticResource 的 contribution
2323
staticResourceClientAppContribution.initialize();
24-
it('express 模块提供 file schema 的 uri 转换', () => {
24+
it('User express module to transform URI', () => {
2525
const uri = staticResourceService.resolveStaticResource(URI.file('test'));
2626
expect(uri.toString()).toEqual('http://127.0.0.1:8000/assets/test');
2727
});

packages/extension/__tests__/browser/extension.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ describe('extension browser test', () => {
9292
extension.initialize();
9393

9494
// 注入语言包后
95-
expect(extension.toJSON().displayName).toEqual('哈哈哈哈啊哈哈');
96-
expect(extension.localize('displayName')).toEqual('哈哈哈哈啊哈哈');
95+
expect(extension.toJSON().displayName).toEqual('中文测试');
96+
expect(extension.localize('displayName')).toEqual('中文测试');
9797
}, 0);
9898
});
9999

packages/extension/__tests__/hosted/api/vscode/ext.host.env.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ describe('vscode extHostEnv Test', () => {
147147
},
148148
});
149149

150-
it('用户首次访问时间大于一天', async () => {
150+
it("The user's first visit is more than a day old", async () => {
151151
const envApi = createEnvApiFactory(
152152
rpcProtocolExt,
153153
extensionService,
@@ -158,7 +158,7 @@ describe('vscode extHostEnv Test', () => {
158158
expect(envApi.isNewAppInstall).toBe(false);
159159
});
160160

161-
it('用户首次访问时间小于一天', () => {
161+
it("The user's first visit is less than a day old", () => {
162162
const envApi = createEnvApiFactory(
163163
rpcProtocolExt,
164164
extensionService,

packages/extension/src/browser/sumi/main.thread.layout.ts

+16-14
Original file line numberDiff line numberDiff line change
@@ -32,38 +32,38 @@ export class MainThreadLayout extends Disposable implements IMainThreadLayout {
3232
}
3333

3434
$setTitle(id: string, title: string): void {
35-
this.getHandler(id).updateTitle(title);
35+
this.getHandler(id)?.updateTitle(title);
3636
}
3737

3838
$setIcon(id: string, iconPath: string): void {
3939
const iconClass = this.iconService.fromIcon('', iconPath, IconType.Background, IconShape.Square);
40-
this.getHandler(id).setIconClass(iconClass!);
40+
this.getHandler(id)?.setIconClass(iconClass!);
4141
}
4242

4343
$setSize(id: string, size: number): void {
44-
this.getHandler(id).setSize(size);
44+
this.getHandler(id)?.setSize(size);
4545
}
4646

4747
$activate(id: string): void {
48-
this.getHandler(id).activate();
48+
this.getHandler(id)?.activate();
4949
}
5050

5151
$deactivate(id: string): void {
52-
this.getHandler(id).deactivate();
52+
this.getHandler(id)?.deactivate();
5353
}
5454

5555
$setBadge(id: string, badge: string): void {
56-
this.getHandler(id).setBadge(badge);
56+
this.getHandler(id)?.setBadge(badge);
5757
}
5858

5959
async $setVisible(id: string, visible: boolean) {
6060
if (visible) {
61-
this.getHandler(id).show();
61+
this.getHandler(id)?.show();
6262
} else {
63-
if (this.getHandler(id).isActivated()) {
64-
this.getHandler(id).deactivate();
63+
if (this.getHandler(id)?.isActivated()) {
64+
this.getHandler(id)?.deactivate();
6565
}
66-
this.getHandler(id).hide();
66+
this.getHandler(id)?.hide();
6767
}
6868
}
6969

@@ -75,8 +75,10 @@ export class MainThreadLayout extends Disposable implements IMainThreadLayout {
7575
} else {
7676
const disposer = this.eventBus.on(TabBarRegistrationEvent, (e) => {
7777
if (e.payload.tabBarId === id) {
78-
const handle = this.layoutService.getTabbarHandler(id);
79-
this.bindHandleEvents(handle!);
78+
const handler = this.layoutService.getTabbarHandler(id);
79+
if (handler) {
80+
this.bindHandleEvents(handler);
81+
}
8082
disposer.dispose();
8183
}
8284
});
@@ -103,8 +105,8 @@ export class MainThreadLayout extends Disposable implements IMainThreadLayout {
103105
protected getHandler(id: string) {
104106
const handler = this.layoutService.getTabbarHandler(id);
105107
if (!handler) {
106-
this.logger.warn(`MainThreaLayout:没有找到${id}对应的handler`);
108+
this.logger.warn(`Could not find a handler with \`${id}\``);
107109
}
108-
return handler!;
110+
return handler;
109111
}
110112
}

packages/extension/src/browser/vscode/contributes/localization.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class LocalizationsContributionPoint extends VSCodeContributePoint<Locali
6969
json = parseWithComments(content);
7070
return json;
7171
} catch (error) {
72-
return this.logger.error('语言配置文件解析出错!', content);
72+
return this.logger.error(`Language configuration file parsing error, ${error.stack}`);
7373
}
7474
}
7575

packages/file-service/src/browser/file-service-client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ export class FileServiceClient implements IFileServiceClient {
426426

427427
registerProvider(scheme: string, provider: FileSystemProvider): IDisposable {
428428
if (this.fsProviders.has(scheme)) {
429-
throw new Error(`'${scheme}' 的文件系统 provider 已存在`);
429+
throw new Error(`The file system provider for \`${scheme}\` already registered`);
430430
}
431431

432432
const disposables: IDisposable[] = [];
@@ -513,7 +513,7 @@ export class FileServiceClient implements IFileServiceClient {
513513
const _uri = new URI(uri);
514514

515515
if (!_uri.scheme) {
516-
throw new Error(`没有设置 scheme: ${uri}`);
516+
throw new Error(`Unsupported convert Uri with non-scheme Uri: ${uri}`);
517517
}
518518

519519
return _uri;

packages/file-service/src/node/file-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ export class FileService implements IFileService {
388388
const _uri = new URI(uri);
389389

390390
if (!_uri.scheme) {
391-
throw new Error(`没有设置 scheme: ${uri}`);
391+
throw new Error(`Unsupported to get Uri from non-scheme Uri: ${uri}`);
392392
}
393393

394394
return _uri;

packages/i18n/src/common/en-US.lang.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,9 @@ export const localizationBundle = {
13611361
// #endregion merge editor
13621362
'workbench.quickOpen.preserveInput':
13631363
'Controls whether the last typed input to Quick Open(include Command Palette) should be preserved.',
1364+
1365+
'webview.webviewTagUnavailable': 'Webview is unsupported on non-electron env, please use iframe instead',
1366+
13641367
...browserViews,
13651368
},
13661369
};

packages/i18n/src/common/zh-CN.lang.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,9 @@ export const localizationBundle = {
10791079
'mergeEditor.conflict.action.apply.confirm.complete': '确认保存并更改',
10801080
'mergeEditor.button.apply': '应用更改',
10811081
'workbench.quickOpen.preserveInput': '是否在 QuickOpen 的输入框(包括命令面板)中保留上次输入的内容',
1082+
1083+
'webview.webviewTagUnavailable': '非 Electron 环境不支持 Webview 标签,请使用 Iframe 标签',
1084+
10821085
...browserViews,
10831086
},
10841087
};

packages/logs-core/__tests__/node/log.service.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('LogService', () => {
6464
console.log('text', text);
6565
if (text.trim().length < 1) {
6666
// eslint-disable-next-line no-console
67-
return console.warn('spdlog 写入文件可能失败了、或者 spdlog 初始化失败!');
67+
return console.warn('Spdlog may have failed to write to file, or initialization failed');
6868
}
6969
expect(text.indexOf(LogLevelMessageMap[LogLevel.Verbose]) < 0).toBe(true);
7070
expect(text.indexOf(LogLevelMessageMap[LogLevel.Debug]) < 0).toBe(true);

0 commit comments

Comments
 (0)