Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(sheet): add zen edit shortcut i18n (#1282)

Ran Luo720aa4ac0531
diff --git a/packages/sheets-zen-editor/src/controllers/shortcuts/zen-editor.shortcut.ts b/packages/sheets-zen-editor/src/controllers/shortcuts/zen-editor.shortcut.ts
index 97da18be92..44117f62ae 100644
--- a/packages/sheets-zen-editor/src/controllers/shortcuts/zen-editor.shortcut.ts
+++ b/packages/sheets-zen-editor/src/controllers/shortcuts/zen-editor.shortcut.ts
@@ -22,7 +22,7 @@ import { CancelZenEditCommand, ConfirmZenEditCommand } from '../../commands/comm
export const ZenEditorConfirmShortcut: IShortcutItem = {
id: ConfirmZenEditCommand.id,
- description: 'shortcut.sheets-zen-editor.confirm',
+ description: 'shortcut.sheet.zen-edit-confirm',
group: '4_sheet-edit',
preconditions: (contextService) => whenZenEditorActivated(contextService),
binding: KeyCode.ENTER | MetaKeys.ALT,
@@ -30,7 +30,7 @@ export const ZenEditorConfirmShortcut: IShortcutItem = {
export const ZenEditorCancelShortcut: IShortcutItem = {
id: CancelZenEditCommand.id,
- description: 'shortcut.sheets-zen-editor.cancel',
+ description: 'shortcut.sheet.zen-edit-cancel',
group: '4_sheet-edit',
preconditions: (contextService) => whenZenEditorActivated(contextService),
binding: KeyCode.ESC,
diff --git a/packages/sheets-zen-editor/src/locale/en-US.ts b/packages/sheets-zen-editor/src/locale/en-US.ts
new file mode 100644
index 0000000000..633f492a23
--- /dev/null
+++ b/packages/sheets-zen-editor/src/locale/en-US.ts
@@ -0,0 +1,24 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export default {
+ shortcut: {
+ sheet: {
+ 'zen-edit-cancel': 'Cancel Zen Edit',
+ 'zen-edit-confirm': 'Confirm Zen Edit',
+ },
+ },
+};
diff --git a/packages/sheets-zen-editor/src/locale/index.ts b/packages/sheets-zen-editor/src/locale/index.ts
new file mode 100644
index 0000000000..1eff5fc204
--- /dev/null
+++ b/packages/sheets-zen-editor/src/locale/index.ts
@@ -0,0 +1,18 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export { default as enUS } from './en-US';
+export { default as zhCN } from './zh-CN';
diff --git a/packages/sheets-zen-editor/src/locale/zh-CN.ts b/packages/sheets-zen-editor/src/locale/zh-CN.ts
new file mode 100644
index 0000000000..b69ec7cbd0
--- /dev/null
+++ b/packages/sheets-zen-editor/src/locale/zh-CN.ts
@@ -0,0 +1,24 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export default {
+ shortcut: {
+ sheet: {
+ 'zen-edit-cancel': '取消编辑(禅模式状态)',
+ 'zen-edit-confirm': '放弃编辑(禅模式状态)',
+ },
+ },
+};
diff --git a/packages/sheets-zen-editor/src/plugin.ts b/packages/sheets-zen-editor/src/plugin.ts
index b7f1128546..9622196f68 100644
--- a/packages/sheets-zen-editor/src/plugin.ts
+++ b/packages/sheets-zen-editor/src/plugin.ts
@@ -14,13 +14,14 @@
* limitations under the License.
*/
-import { Plugin, PluginType } from '@univerjs/core';
+import { LocaleService, Plugin, PluginType } from '@univerjs/core';
import type { Dependency } from '@wendellhu/redi';
import { Inject, Injector } from '@wendellhu/redi';
import { ZenEditorController } from './controllers/zen-editor.controller';
import { ZenEditorUIController } from './controllers/zen-editor-ui.controller';
import { IZenEditorManagerService, ZenEditorManagerService } from './services/zen-editor.service';
+import { zhCN } from './locale';
export interface IUniverSheetsZenEditorPluginConfig {}
export class UniverSheetsZenEditorPlugin extends Plugin {
@@ -28,12 +29,20 @@ export class UniverSheetsZenEditorPlugin extends Plugin {
constructor(
config: IUniverSheetsZenEditorPluginConfig,
- @Inject(Injector) override readonly _injector: Injector
+ @Inject(Injector) override readonly _injector: Injector,
+ @Inject(LocaleService) private readonly _localeService: LocaleService
) {
super('zen-editor');
+ this._initialize();
this._initializeDependencies(this._injector);
}
+ private _initialize(): void {
+ this._localeService.load({
+ zhCN,
+ });
+ }
+
private _initializeDependencies(injector: Injector) {
const dependencies: Dependency[] = [
[ZenEditorUIController],