From 93b63c7be15987f0995c72f369efc699045f32c8 Mon Sep 17 00:00:00 2001 From: bjorn Date: Tue, 10 Dec 2024 23:46:29 +0800 Subject: [PATCH] refactor: update i18n --- README.md | 10 +++++----- package.json | 4 ++-- src/i18n.ts | 22 ++++++++++++++++++++-- src/index.ts | 13 +++++++++++-- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2eb87e1..ef51c14 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,11 @@ auto generate instruction for cursor / copilot. -| Command | Title | -| ---------------------- | ------------------------------- | -| `cig.selectAIPrompt` | CIG: Generate Instruction | -| `cig.searchAIPrompt` | CIG: Search and Add Instruction | -| `cig.clearGlobalState` | CIG: Clear Extension State | +| Command | Title | +| ---------------------- | ------------------------------------ | +| `cig.selectAIPrompt` | CIG: Browse Instructions by Category | +| `cig.searchAIPrompt` | CIG: Search Instructions by Keyword | +| `cig.clearGlobalState` | CIG: Clear Extension State | diff --git a/package.json b/package.json index 0479563..f3f9109 100644 --- a/package.json +++ b/package.json @@ -40,12 +40,12 @@ "commands": [ { "command": "cig.selectAIPrompt", - "title": "Generate Instruction", + "title": "Browse Instructions by Category", "category": "CIG" }, { "command": "cig.searchAIPrompt", - "title": "Search and Add Instruction", + "title": "Search Instructions by Keyword", "category": "CIG" }, { diff --git a/src/i18n.ts b/src/i18n.ts index ea7095b..40c4d77 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -12,9 +12,27 @@ interface LocalizedMessages { yes: string no: string configEnableAutoDetect: string + confirmOverwrite: string + overwrite: string } const zhCN: LocalizedMessages = { + searchPlaceholder: '搜索规则...', + noAIConfigFound: '未检测到 AI 配置文件。是否要创建一个?', + searchAndCreate: '搜索并创建', + ignoreProject: '忽略项目', + cancel: '取消', + ruleAddedSuccess: (title: string) => `规则 "${title}" 添加成功`, + clearStateConfirm: '确定要清除所有已保存的扩展状态吗?这将重置所有被忽略的项目。', + clearStateSuccess: '扩展状态已清除', + yes: '是', + no: '否', + configEnableAutoDetect: '自动检测并提示创建 AI 配置文件', + confirmOverwrite: '这将覆盖现有的 AI 配置文件。是否继续?', + overwrite: '覆盖', +} + +const enUS: LocalizedMessages = { searchPlaceholder: 'Search rules...', noAIConfigFound: 'No AI config file detected. Would you like to create one?', searchAndCreate: 'Search and Create', @@ -26,10 +44,10 @@ const zhCN: LocalizedMessages = { yes: 'Yes', no: 'No', configEnableAutoDetect: 'Automatically detect and prompt to create AI config files', + confirmOverwrite: 'This will overwrite the existing AI config file. Do you want to continue?', + overwrite: 'Overwrite', } -const enUS: LocalizedMessages = { ...zhCN } - const messages: Record = { 'zh-cn': zhCN, 'en': enUS, diff --git a/src/index.ts b/src/index.ts index 3c88499..cdfe466 100644 --- a/src/index.ts +++ b/src/index.ts @@ -190,8 +190,17 @@ export function activate(context: vscode.ExtensionContext) { async function writeRuleToFile(sections: Section[]) { const rule = findCurrentRule(sections) if (rule) { - await insertPromptToFile(rule.content) - vscode.window.showInformationMessage(`Rule "${currentRule}" written successfully.`) + const messages = getLocaleMessages() + const result = await vscode.window.showWarningMessage( + messages.confirmOverwrite, + messages.overwrite, + messages.cancel + ) + + if (result === messages.overwrite) { + await insertPromptToFile(rule.content) + vscode.window.showInformationMessage(messages.ruleAddedSuccess(currentRule!)) + } } }