Skip to content

feat(ui): init l10n - #8

Merged
MalachiteN merged 2 commits into
NERDSORG:mainfrom
emikeliu:l10n
Aug 2, 2026
Merged

feat(ui): init l10n#8
MalachiteN merged 2 commits into
NERDSORG:mainfrom
emikeliu:l10n

Conversation

@emikeliu

@emikeliu emikeliu commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Fixed issue #3.
This Pull Request contains AI-generated content.
该PR含有AI生成内容。

实现内容

1. package.json 贡献点本地化(NLS)

package.json 中:

  • 顶层新增 "l10n": "./l10n" 字段,指向 l10n bundle 目录
  • 所有 contributes 中的 displayName、视图名称、命令 titleconfiguration 描述等硬编码字符串全部替换为 %key% 占位符

新增两个 NLS 文件(VS Code 根据 package.nls.<locale>.json 命名约定自动加载):

  • package.nls.json — 英语基线
  • package.nls.zh-cn.json — 简体中文

2. 运行时字符串本地化(l10n bundle)

新增 src/i18n.ts,封装 vscode.l10n.t(),提供 t(message, ...args) 简洁导入,支持 {0}/{1} 占位符替换。

新增 l10n bundle 文件(由 package.json"l10n" 字段指向):

3. 源码替换

将以下文件中所有面向用户的通知、QuickPick、tooltip、状态栏、Output 通道名称等替换为 t() 调用:

工作机制

VS Code 根据用户界面语言("locale": "zh-cn")自动选择对应 bundle:

  • package.nls.json / l10n/bundle.l10n.json:英语(默认回退)
  • package.nls.zh-cn.json / l10n/bundle.l10n.zh-cn.json:简体中文

用户将 VS Code 显示语言切换为中文后,命令面板、侧边栏、设置页、通知、tooltip 等均显示中文;切回英文则显示英文,无需修改任何代码或配置。

Summary by Sourcery

为 VS Code 插件 UI 引入完整的本地化支持,包括运行时字符串和配置,并提供英文和简体中文资源包。

新特性:

  • 添加 VS Code l10n 资源包接入和辅助工具,用于本地化运行时消息、通知和状态文本。
  • 使用 NLS 占位符本地化所有 package.json 中的 contributes 元数据,并提供英文和简体中文资源。
Original summary in English

Summary by Sourcery

Introduce full localization support for the VS Code extension UI, including runtime strings and configuration, with English and Simplified Chinese bundles.

New Features:

  • Add VS Code l10n bundle wiring and helper to localize runtime messages, notifications, and status texts.
  • Localize all package.json contributes metadata using NLS placeholders with English and Simplified Chinese resources.

@sourcery-ai

sourcery-ai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Reviewer's Guide

为 Mutsumi VS Code 扩展引入完整的本地化(l10n/NLS)支持,覆盖 package.json 中的贡献配置、运行时 UI 文本,以及英文和简体中文的新本地化资源包。

File-Level Changes

Change Details Files
Add VS Code l10n/NLS infrastructure and wire up a lightweight translation helper used across the extension.
  • 在 package.json 中添加指向 l10n 资源包目录的 "l10n" 字段,并将面向用户的贡献字符串替换为用于 NLS 的 %key% 占位符。
  • 创建 package.nls.json 和 package.nls.zh-cn.json,分别作为贡献字符串的英文和简体中文资源文件。
  • 添加 src/i18n.ts,提供对 vscode.l10n.t 的类型封装,方便通过 t(key, ...args) 使用占位符替换。
  • 添加 l10n/bundle.l10n.json 和 l10n/bundle.l10n.zh-cn.json,作为运行时本地化资源包,通过代码中的 t() 引用。
package.json
package.nls.json
package.nls.zh-cn.json
src/i18n.ts
l10n/bundle.l10n.json
l10n/bundle.l10n.zh-cn.json
Localize core commands, notebook interactions, and HTTP server messaging in the extension activation flow.
  • 在 src/extension.ts 中引入 t(),并将硬编码的 HTTP 服务器警告、密码生成成功消息以及 notebook 控制器显示名称替换为本地化的键值。
  • 本地化新建 Agent 工作流:QuickPick 标题/占位符、详细类型描述字符串以及创建后的确认消息现在使用带动态参数的 t()。
  • 通过 t() 本地化 copy-reference 的错误/状态栏消息,以及 clearToolCache 完成通知。
src/extension.ts
Localize notebook command flows for model selection, compression, context debugging, ghost block pruning, session renaming, auto-approve toggling, and RAG search.
  • 在 Select Model 命令中使用 t() 为推理工作量描述、分隔符、占位符以及成功/错误消息提供本地化。
  • 将 compressConversation、debugContext、pruneGhostBlocks 和 testRagSearch 中的 notebook 编辑器存在/类型检查、进度标题以及错误/警告消息替换为包含动态值的本地化字符串。
  • 通过 t() 本地化 renameSession 的提示和成功/失败通知,包括重新生成的标题。
  • 本地化 toggleAutoApprove 命令中的自动批准切换消息和错误信息。
src/notebook/commands/selectModel.ts
src/notebook/commands/compressConversation.ts
src/notebook/commands/debugContext.ts
src/notebook/commands/pruneGhostBlocks.ts
src/notebook/commands/renameSession.ts
src/notebook/commands/toggleAutoApprove.ts
src/notebook/commands/testRagSearch.ts
Localize sidebar tree items for agents, approvals, shell tasks, and context items, including tooltips and status labels.
  • 使用 t() 翻译 Agent 运行时状态标签以及 agent 文件打开错误消息。
  • 本地化 ApprovalTreeItem 的 tooltip 行(目标、自定义操作、详情、时间)以及待处理/已批准/已拒绝状态文本映射。
  • 本地化 ShellTaskTreeItem 的描述字符串、tooltip 标签(CWD、任务 ID、agent 会话、模式、状态、输出),以及包含可选信号的退出信息格式。
  • 本地化 ContextTreeItem 的类别标签、激活/未激活标注、树刷新通知、规则/技能/文件读取错误、文件未找到消息、规则/技能激活/停用通知,以及“没有更旧版本”消息。
src/sidebar/agentTreeItem.ts
src/sidebar/approvalTreeItem.ts
src/sidebar/shellTaskTreeItem.ts
src/sidebar/contextTreeItem.ts
Localize completion provider UI text and tool-related notifications and rejection flows.
  • 使用 t() 为补全项详情/文档进行本地化,例如文件引用、目录引用、通用工具描述以及 "Tool Call" 标签。
  • 在 tools.d/permission 中本地化拒绝输入提示/占位符,以及拒绝流程返回的文本摘要。
  • 在 src/notifications.ts 中本地化外部桌面通知文本,用于“需要审批”的事件。
src/notebook/completionProvider.ts
src/tools.d/permission.ts
src/notifications.ts
Localize logging channels and tool-related error messaging for agent runs and file editing.
  • 通过 t() 创建调试和工具输出通道的本地化名称,替代硬编码英文。
  • 本地化 agentRunner 中的 LLM 错误通知,并将 "Copy Details" 按钮标签保留在资源包中,以便在 agentRunner 和 controller 错误路径中使用。
  • 在 edit_file 工具中本地化 "Failed to reopen editor" 错误消息。
src/debugLogger.ts
src/tools.d/toolsLogger.ts
src/agent/agentRunner.ts
src/controller.ts
src/tools.d/edit_file.ts

Tips and commands

Interacting with Sourcery

  • 触发新评审: 在 Pull Request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的评审评论。
  • 从评审评论生成 GitHub issue: 通过回复评审评论请求 Sourcery 根据该评论创建 issue。你也可以在评审评论中回复 @sourcery-ai issue 来创建对应的 issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题中任意位置写上 @sourcery-ai,即可在任何时间生成标题。你也可以在 Pull Request 中评论 @sourcery-ai title 随时(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 内容中任意位置写上 @sourcery-ai summary,即可在你指定的位置生成 PR 摘要。你也可以在 Pull Request 中评论 @sourcery-ai summary 随时(重新)生成摘要。
  • 生成评审指南: 在 Pull Request 中评论 @sourcery-ai guide,即可在任何时间(重新)生成评审者指南。
  • 一次性解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 一次性关闭所有 Sourcery 评审: 在 Pull Request 中评论 @sourcery-ai dismiss,即可关闭所有现有的 Sourcery 评审。尤其适用于你想从头开始新的评审——别忘了评论 @sourcery-ai review 来触发新的评审!

Customizing Your Experience

访问你的 dashboard 以:

  • 启用或禁用评审功能,例如 Sourcery 生成的 Pull Request 摘要、评审者指南等。
  • 更改评审语言。
  • 添加、删除或编辑自定义评审说明。
  • 调整其他评审设置。

Getting Help

Original review guide in English

Reviewer's Guide

Introduce full localization (l10n/NLS) support for the Mutsumi VS Code extension, covering package.json contributions, runtime UI strings, and new localization bundles for English and Simplified Chinese.

File-Level Changes

Change Details Files
Add VS Code l10n/NLS infrastructure and wire up a lightweight translation helper used across the extension.
  • Add "l10n" field in package.json pointing to the l10n bundle directory and replace user-facing contribution strings with %key% placeholders for NLS.
  • Create package.nls.json and package.nls.zh-cn.json as the English and Simplified Chinese resource files for contribution strings.
  • Add src/i18n.ts providing a typed wrapper around vscode.l10n.t for convenient t(key, ...args) usage with placeholder substitution.
  • Add l10n/bundle.l10n.json and l10n/bundle.l10n.zh-cn.json as runtime localization bundles referenced from code via t().
package.json
package.nls.json
package.nls.zh-cn.json
src/i18n.ts
l10n/bundle.l10n.json
l10n/bundle.l10n.zh-cn.json
Localize core commands, notebook interactions, and HTTP server messaging in the extension activation flow.
  • Import t() in src/extension.ts and replace hard-coded HTTP server warnings, password generation success messages, and notebook controller display name with localized keys.
  • Localize the New Agent workflow: QuickPick titles/placeholders, detailed type description string, and post-creation confirmation messages now use t() with dynamic arguments.
  • Localize copy-reference error/status-bar messages and clearToolCache completion notification via t().
src/extension.ts
Localize notebook command flows for model selection, compression, context debugging, ghost block pruning, session renaming, auto-approve toggling, and RAG search.
  • Use t() for reasoning effort descriptions, separators, placeholders, and success/error messages in the Select Model command.
  • Replace notebook editor presence/type checks, progress titles, and error/warning messages in compressConversation, debugContext, pruneGhostBlocks, and testRagSearch with localized strings including dynamic values.
  • Localize renameSession prompt and success/failure notifications, including regenerated titles, via t().
  • Localize auto-approve toggle messages and errors in toggleAutoApprove commands.
src/notebook/commands/selectModel.ts
src/notebook/commands/compressConversation.ts
src/notebook/commands/debugContext.ts
src/notebook/commands/pruneGhostBlocks.ts
src/notebook/commands/renameSession.ts
src/notebook/commands/toggleAutoApprove.ts
src/notebook/commands/testRagSearch.ts
Localize sidebar tree items for agents, approvals, shell tasks, and context items, including tooltips and status labels.
  • Use t() to translate Agent runtime status labels and agent file open error messages.
  • Localize ApprovalTreeItem tooltip lines (target, custom action, details, time) and status text mapping for pending/approved/rejected.
  • Localize ShellTaskTreeItem description strings, tooltip labels (CWD, task ID, agent session, mode, status, output), and exit formatting including optional signal.
  • Localize ContextTreeItem category labels, active/inactive annotations, tree refresh notifications, rule/skill/file read errors, file-not-found messages, activation/deactivation notifications for rules/skills, and no-older-versions messages.
src/sidebar/agentTreeItem.ts
src/sidebar/approvalTreeItem.ts
src/sidebar/shellTaskTreeItem.ts
src/sidebar/contextTreeItem.ts
Localize completion provider UI text and tool-related notifications and rejection flows.
  • Use t() for completion item detail/documentation such as file reference, directory reference, generic tool descriptions, and the "Tool Call" label.
  • Localize rejection input prompts/placeholders and the textual summaries returned by the rejection flow in tools.d/permission.
  • Localize external desktop notification text for approval-needed events in src/notifications.ts.
src/notebook/completionProvider.ts
src/tools.d/permission.ts
src/notifications.ts
Localize logging channels and tool-related error messaging for agent runs and file editing.
  • Create localized names for the debug and tools output channels via t() instead of hard-coded English.
  • Localize agentRunner LLM error notifications and keep the "Copy Details" button label in the bundle for both agentRunner and controller error paths.
  • Localize the "Failed to reopen editor" error message in the edit_file tool.
src/debugLogger.ts
src/tools.d/toolsLogger.ts
src/agent/agentRunner.ts
src/controller.ts
src/tools.d/edit_file.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗨,我给出了一些整体层面的反馈:

  • 建议统一本地化(l10n)键的命名方式(例如使用类似 debug.outputChannel.title 这样的命名空间标识符,而不是重复使用面向用户的文案字符串,比如 t('Mutsumi Debug')),这样可以让本地化包更易于维护,并避免键名意外冲突。
  • 对于包含结构化内容的消息(例如侧边栏树条目中的 Markdown 提示),把完整的 Markdown 模板保存在 l10n 包中可能会更清晰,而不是在代码中拼接多个已本地化片段,这样译者可以查看并调整整条字符串的布局。
给 AI Agents 的提示词
Please address the comments from this code review:

## Overall Comments
- Consider standardizing l10n keys (e.g., using namespaced identifiers like `debug.outputChannel.title` instead of reusing user-facing strings such as `t('Mutsumi Debug')`) to keep the bundles easier to maintain and to avoid accidental key collisions.
- For messages that embed structured content (e.g., Markdown tooltips in sidebar tree items), it may be clearer to keep the full Markdown template in the l10n bundle rather than concatenating localized fragments in code, so translators can see and adjust the entire string layout.

Sourcery 对开源项目免费 —— 如果你觉得我们的代码审查有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据这些反馈来改进后续的代码审查。
Original comment in English

Hey - I've left some high level feedback:

  • Consider standardizing l10n keys (e.g., using namespaced identifiers like debug.outputChannel.title instead of reusing user-facing strings such as t('Mutsumi Debug')) to keep the bundles easier to maintain and to avoid accidental key collisions.
  • For messages that embed structured content (e.g., Markdown tooltips in sidebar tree items), it may be clearer to keep the full Markdown template in the l10n bundle rather than concatenating localized fragments in code, so translators can see and adjust the entire string layout.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider standardizing l10n keys (e.g., using namespaced identifiers like `debug.outputChannel.title` instead of reusing user-facing strings such as `t('Mutsumi Debug')`) to keep the bundles easier to maintain and to avoid accidental key collisions.
- For messages that embed structured content (e.g., Markdown tooltips in sidebar tree items), it may be clearer to keep the full Markdown template in the l10n bundle rather than concatenating localized fragments in code, so translators can see and adjust the entire string layout.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

- move notebookController.displayName from package.nls.* to runtime bundle
- add missing notebook.noCodeCell to zh-cn bundle
- localize approval flow content strings (shell/mkdir/edit actions)
- localize selectModel current marker and default effort row
- keep LLM-facing rejection messages in English
- remove dead keys, unify output channel key style, fix whitespace
@MalachiteN
MalachiteN merged commit 2f6501f into NERDSORG:main Aug 2, 2026
2 checks passed
@emikeliu
emikeliu deleted the l10n branch August 3, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants