Skip to content

feat(build): translate build option text through build.localizeOptions - #122

Merged
1lck merged 2 commits into
mainfrom
feat/build-option-l10n
Nov 19, 2026
Merged

1lck merged 2 commits into
mainfrom
feat/build-option-l10n

Conversation

@1lck

@1lck 1lck commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

关联 Issue / Linked issue

PR 类型 / Type

  • feat

改动说明

构建选项的名称、说明和固定选项值的标题只能用插件清单里的英文,中文界面下 Maven 的 “Settings File”“Local Repository”“Offline” 都是英文。运行配置类型已经能用包内翻译文件 l10n/<语言>.json 翻译,构建选项还不行。

翻译文件新增 buildOptions

  • 写法:buildOptions.<buildSystemID>.<optionID>: { displayName?, description?, choices?: { <value>: title } }。
  • 规则与 runConfigurationTypes 一样:只替换清单里已有的文字,不改名、不增加、不调整顺序;字数限制和清单相同。以下情况整份文件拒绝,错误码 plugin.build.invalidLocalization,宿主改用下一个候选文件或清单原文:
    • 文件写了未声明的构建系统、选项或选项值;
    • 给清单里没有 description 的选项写了说明。
  • plugin-l10n.schema.json 新增 buildOptions 和 $defs.optionText。

新命令 build.localizeOptions

  • 请求:{ language?, plugins: [{ manifest, localizations? }] }。
  • 返回:{ manifests, localizations }。
    • manifests:每个插件一份,顺序与请求一致;替换了 buildSystems[].options[] 的 displayName、description 和选项值的 title,其余原样保留。
    • localizations:每个声明了构建选项的插件一份报告,格式与 plugins.settings、runConfig.configurationTypes 相同(readRequired、candidates、applied、rejected)。
  • 采用和运行配置类型相同的两阶段协议:宿主先不带文件发送,再从已安装的插件包里读取 Core 列出的候选文件,然后带着文件再发一次。
  • 为什么替换清单而不是逐个命令带翻译:选项名会出现在选项对话框(build.resolveOptions)、运行配置编辑器、工具栏开关和构建树的选项节点上,这些都读检测到的实例的清单。在检测前换掉清单,一处就能覆盖所有界面。翻译后的清单仍通过校验,选项 ID、值和参数都不变,所以计划和指纹不受影响(测试中对翻译后的清单重新做了校验)。
  • 新模块 rust/crates/build/src/option_text.rs;BuildCommand::LocalizeOptions 已在协议表和分发器中注册。

文档

  • 契约 README:翻译文件成员表、plugin.build.invalidLocalization 错误码、构建选项表和 Commands 一节。
  • rust-core-api.md:命令表与请求/返回表新增 build.localizeOptions,并补上 feat(build): report the implicit value of unset path options and option descriptions #120 新增的 build.resolveOptions 返回字段(description、implicitValue)。
  • reference/domains/build-systems.md 中英文同步。
  • 插件协议更新记录在 2026-11-19 新增一行(API-29、API-37)。

验证

  • 新增测试 build_option_text_is_translated_in_the_manifest,覆盖:
    • 第一次请求列出候选文件,清单不变;
    • 第二次请求替换名称、说明和选项值标题,翻译后的清单仍通过校验;
    • 四种不合规文件(未声明的选项、清单没有的说明、未声明的选项值、未声明的构建系统)都整份拒绝,清单不变;
    • 没有语言时原样返回。
  • cargo test -p lithe-build -p lithe-core -p lithe-plugin-manifest 通过(lithe-core 859 项)。
  • cargo clippy -D warnings、cargo fmt --check、verify-rust-core-comments.sh build、verify-platform-tests.mjs、verify-docs.mjs 通过。
  • 插件后端协议没有改动,不需要运行 sdk-e2e。没有新增宿主方法或通知。

🤖 Generated with Claude Code

1lck and others added 2 commits November 19, 2026 04:48
Plugins may translate an option's displayName, description and declared
choice titles under buildOptions.<buildSystemID>.<optionID> in
l10n/<language>.json. build.localizeOptions takes the enabled build plugins'
manifests and the interface language, names the files to read like
runConfig.configurationTypes, and returns the manifests with the option text
replaced, so every host surface that reads the manifest shows it. A file that
does not fit is refused whole as plugin.build.invalidLocalization.

Refs 1lck/Lithe-IDEA#2204

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@1lck
1lck marked this pull request as ready for review November 19, 2026 12:49
@1lck
1lck merged commit 7ca5134 into main Nov 19, 2026
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.

1 participant