Skip to content

Commit b1de2fa

Browse files
committed
feat: 增加是否显示快捷键提示的开关(默认开启)
1 parent 72566fc commit b1de2fa

11 files changed

Lines changed: 158 additions & 8 deletions

File tree

.trae/skills/create-setting-item/SKILL.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,11 @@ export const settingsIcons = {
5858

5959
### 3. 添加翻译文本
6060

61-
在所有语言文件中添加翻译:
61+
> **注意:** 关于翻译管理的详细说明,请参考 `manage-translations` skill。
6262
63-
- `app/src/locales/zh_CN.yml` - 简体中文
64-
- `app/src/locales/zh_TW.yml` - 繁体中文
65-
- `app/src/locales/en.yml` - 英文
66-
- `app/src/locales/zh_TWC.yml` - 接地气繁体中文
67-
- `app/src/locales/id.yml` - 印度尼西亚语
63+
在所有语言文件中添加翻译。首先查看 `app/src/locales/` 目录下有哪些 `.yml` 文件,然后为每个语言文件添加翻译。
6864

69-
**翻译结构**
65+
**设置项的翻译结构**
7066

7167
```yaml
7268
settings:
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
name: manage-translations
3+
description: "指导如何在 Project Graph 项目中管理多语言翻译。当需要添加新翻译、更新现有翻译或了解翻译系统结构时使用此技能。"
4+
---
5+
6+
# 管理翻译
7+
8+
本技能指导如何在 Project Graph 项目中管理多语言翻译。
9+
10+
## 翻译文件位置
11+
12+
所有翻译文件位于 `app/src/locales/` 目录下:
13+
14+
```
15+
app/src/locales/
16+
├── en.yml # 英文
17+
├── id.yml # 印度尼西亚语
18+
├── zh_CN.yml # 简体中文
19+
├── zh_TW.yml # 繁体中文
20+
├── zh_TWC.yml # 接地气繁体中文
21+
└── README.md # 翻译系统说明
22+
```
23+
24+
## 查看当前支持的语言
25+
26+
在添加或修改翻译前,先查看 `app/src/locales/` 目录下有哪些 `.yml` 文件:
27+
28+
```bash
29+
ls app/src/locales/*.yml
30+
```
31+
32+
## 添加新翻译
33+
34+
### 1. 确定翻译键名
35+
36+
翻译使用层级结构,通常按功能模块组织:
37+
38+
```yaml
39+
# 基本结构
40+
moduleName:
41+
featureName:
42+
title: "标题文本"
43+
description: "描述文本"
44+
```
45+
46+
### 2. 在所有语言文件中添加
47+
48+
为每个 `.yml` 文件添加对应的翻译。例如添加一个设置项的翻译:
49+
50+
**zh_CN.yml:**
51+
52+
```yaml
53+
settings:
54+
enableNewFeature:
55+
title: "启用新功能"
56+
description: "开启后将启用新功能特性"
57+
options:
58+
option1: "选项一"
59+
option2: "选项二"
60+
```
61+
62+
**en.yml:**
63+
64+
```yaml
65+
settings:
66+
enableNewFeature:
67+
title: "Enable New Feature"
68+
description: "Enable to activate the new feature"
69+
options:
70+
option1: "Option 1"
71+
option2: "Option 2"
72+
```
73+
74+
**其他语言文件同理...**
75+
76+
### 3. 翻译内容规范
77+
78+
- **title**: 简短标题,3-10个字
79+
- **description**: 详细描述,可以包含多行(使用 `|`)
80+
- **options**: 仅枚举类型需要,列出所有选项的显示文本
81+
82+
## 翻译使用方式
83+
84+
### 在代码中使用
85+
86+
```typescript
87+
import i18next from "i18next";
88+
89+
// 简单翻译
90+
const title = i18next.t("settings.enableNewFeature.title");
91+
92+
// 带参数的翻译
93+
const message = i18next.t("common.deleted", { count: 5 });
94+
95+
// 指定命名空间(如 keyBinds)
96+
const keyBindTitle = i18next.t("saveFile.title", { ns: "keyBinds", defaultValue: "" });
97+
```
98+
99+
### 在 React 组件中使用
100+
101+
```tsx
102+
import { useTranslation } from "react-i18next";
103+
104+
function MyComponent() {
105+
const { t } = useTranslation();
106+
107+
return <div>{t("settings.enableNewFeature.title")}</div>;
108+
}
109+
```
110+
111+
## 添加新语言
112+
113+
1. 在 `app/src/locales/` 目录下创建新的 `.yml` 文件
114+
2. 复制现有语言文件(如 `en.yml`)作为模板
115+
3. 将所有值翻译为目标语言
116+
4. 在语言配置中添加新语言(如有语言选择功能)
117+
118+
## 注意事项
119+
120+
1. **保持键名一致**: 所有语言文件中的键名必须完全一致
121+
2. **不要遗漏**: 添加新翻译时,确保为所有语言文件都添加
122+
3. **使用英文作为后备**: 如果某个翻译缺失,系统会回退到英文
123+
4. **参数占位符**: 使用 `{{paramName}}` 语法添加可变参数
124+
5. **多行文本**: 使用 `|` 符号表示多行文本

app/src/core/service/Settings.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ export const settingsSchema = z.object({
207207
soundPitchVariationRange: z.number().min(0).max(1200).int().default(150),
208208
autoImportTxtFileWhenOpenPrg: z.boolean().default(false),
209209
enableAutoEdgeWidth: z.boolean().default(true),
210+
showKeyBindHint: z.boolean().default(true),
210211
});
211212

212213
export type Settings = z.infer<typeof settingsSchema>;

app/src/core/service/SettingsIcons.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
Keyboard,
2929
Languages,
3030
Layers,
31+
Lightbulb,
3132
LineSquiggle,
3233
ListCheck,
3334
ListCollapse,
@@ -201,4 +202,5 @@ export const settingsIcons = {
201202
darkTheme: Moon,
202203
arrowKeySelectOnlyInViewport: ScanEye,
203204
enableAutoEdgeWidth: Minus,
205+
showKeyBindHint: Lightbulb,
204206
};

app/src/core/service/controlService/shortcutKeysEngine/KeyBindHintEngine.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Project, service } from "@/core/Project";
2+
import { Settings } from "@/core/service/Settings";
23
import { allKeyBinds } from "./shortcutKeysRegister";
34
import { parseEmacsKey, parseSingleEmacsKey } from "@/utils/emacs";
45
import { isMac } from "@/utils/platform";
@@ -247,7 +248,7 @@ export class KeyBindHintEngine {
247248
* 渲染快捷键提示
248249
*/
249250
render() {
250-
if (!this.isShowingHint || this.cachedKeyBinds.length === 0) {
251+
if (!Settings.showKeyBindHint || !this.isShowingHint || this.cachedKeyBinds.length === 0) {
251252
return;
252253
}
253254

app/src/locales/en.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,11 @@ settings:
850850
description: |
851851
When enabled, edges connecting two sections will automatically adjust their thickness based on the section size.
852852
When disabled, all edges will use a fixed thickness.
853+
showKeyBindHint:
854+
title: Show Key Bind Hints When Pressing Modifier Keys
855+
description: |
856+
When enabled, matching keyboard shortcut hints will be displayed when pressing modifier keys (Ctrl/Alt/Shift/Win on Windows or ⌘/⌥/⇧/⌃ on Mac).
857+
Hold the modifier key to view the first page of shortcuts, release and press again to page through more.
853858
plugins:
854859
welcome:
855860
title: Welcome to the Plugin System

app/src/locales/id.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,11 @@ settings:
940940
autoImportTxtFileWhenOpenPrg:
941941
title: Impor File TXT dengan Nama Sama Otomatis Saat Buka File PRG
942942
description: Saat diaktifkan, saat membuka file PRG akan mengimpor konten file TXT dengan nama sama di folder yang sama secara otomatis, dan menambahkannya ke sudut kiri bawah panggung sebagai node teks.
943+
showKeyBindHint:
944+
title: Tampilkan Petunjuk Tombol Pintas Saat Menekan Tombol Modifikasi
945+
description: |
946+
Saat diaktifkan, petunjuk tombol pintas yang cocok akan ditampilkan saat menekan tombol modifikasi (Ctrl/Alt/Shift/Win di Windows atau ⌘/⌥/⇧/⌃ di Mac).
947+
Tahan tombol modifikasi untuk melihat halaman pertama tombol pintas, lepaskan dan tekan lagi untuk melihat lebih banyak.
943948
944949
effects:
945950
CircleChangeRadiusEffect:

app/src/locales/zh_CN.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,11 @@ settings:
955955
description: |
956956
开启后,连接两个框(Section)之间的连线会根据框的大小自动调整粗细。
957957
关闭后,所有连线将使用固定粗细。
958+
showKeyBindHint:
959+
title: 按下快捷键修饰键后显示匹配的快捷键提示
960+
description: |
961+
开启后,当按下 Ctrl/Alt/Shift/Win(Windows)或 ⌘/⌥/⇧/⌃(Mac)等修饰键时,会显示匹配的快捷键提示。
962+
按住修饰键不放可查看第一页快捷键,松开后再次按下可翻页查看更多。
958963
959964
960965
effects:

app/src/locales/zh_TW.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,11 @@ settings:
955955
description: |
956956
開啟後,連接兩個框(Section)之間的連線會根據框的大小自動調整粗細。
957957
關閉後,所有連線將使用固定粗細。
958+
showKeyBindHint:
959+
title: 按下快捷鍵修飾鍵後顯示匹配的快捷鍵提示
960+
description: |
961+
開啟後,當按下 Ctrl/Alt/Shift/Win(Windows)或 ⌘/⌥/⇧/⌃(Mac)等修飾鍵時,會顯示匹配的快捷鍵提示。
962+
按住修飾鍵不放可查看第一頁快捷鍵,鬆開後再次按下可翻頁查看更多。
958963
959964
960965
effects:

app/src/locales/zh_TWC.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,11 @@ settings:
964964
description: |
965965
開啟後,連接兩個框(Section)之間的連線會根據框的大小自動調整粗細。
966966
關閉後,所有連線將使用固定粗細。
967+
showKeyBindHint:
968+
title: 按下快捷鍵修飾鍵後顯示匹配的快捷鍵提示
969+
description: |
970+
開啟後,當按下 Ctrl/Alt/Shift/Win(Windows)或 ⌘/⌥/⇧/⌃(Mac)等修飾鍵時,會顯示匹配的快捷鍵提示。
971+
按住修飾鍵不放可查看第一頁快捷鍵,鬆開後再次按下可翻頁查看更多。
967972
effects:
968973
CircleChangeRadiusEffect:
969974
title: 圆形变换半径效果

0 commit comments

Comments
 (0)