Repository navigation
feat(desktop): 插件设置页按界面语言显示插件包自带的翻译 - #1911
Merged
Merged
Conversation
插件可以在包里放 l10n/<语言>.json(Lithe-core-rust#36,API-37)。设置页 现在按界面语言读取:Core 先给出候选文件和上限,宿主经 configfile 从已安装 插件目录只读地取文件,再交给 Core 校验并逐条回退到清单原文。 - pluginsettings:Store.LoadPresented 两步读取,保存后的回读保留译文; 读不了的候选记进 Snapshot.LocalizationReadFailures 并继续下一个 - pluginservice:LoadSettingsEditor 带界面语言,包根即取清单的已安装目录 - settingswindow:界面语言变化后重读文字,有未保存草稿时不重读; 按钮确认弹窗使用译后的按钮标题 - workbench:读不了或被 Core 拒绝的语言文件各记一条 app.notification.operation_rejected(localization_unreadable、 invalid_localization) - Agent Note、API 实施计划 API-37 和功能矩阵同步更新
生成器原来用 spawnSync 把约 450 KB 的桌面词条源码从 stdin 喂给 gofmt。 在 macOS(Node 24.14.0、Go 1.27.4)上,gofmt 偶尔收不到输入结束,会 一直等待:800 次里卡住 2 次,换成 cat 或改用文件参数则不会出现。 spawnSync 还会阻塞事件循环,test-i18n.mjs 的超时也无法终止它。 现在把源码写进系统临时目录下的私有目录,以文件参数异步调用 gofmt, 超时 10 秒,结束后删除该目录。临时文件不在仓库里,--check 仍不改 仓库文件,生成结果逐字节不变。
xiaoyumuxi
marked this pull request as ready for review
November 14, 2026 09:28
This was referenced Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
plugins.declarative.settingsState读取包内l10n/<语言>.json,API-37)。PR 类型 / Type
改动说明 / What changes
背景 / Why
插件设置页上的分组名、设置标题、说明、选项名和按钮名都直接来自
plugin.json,只有插件作者写的那一种语言,所以界面切到中文后插件设置仍是英文。宿主的shared/i18n只翻译宿主自己的文字,不能替每个插件维护词条(那是按插件内容的特判,第三方插件也拿不到)。Core #36 让插件可以在包里自带
l10n/<语言>.json。本 PR 让桌面端按界面语言读取这些文件,并把译文显示出来。改动 / Changes
pluginsettings):Store.LoadPresented先只带界面语言调用settingsState,拿到候选文件(zh-Hans依次是l10n/zh-Hans.json、l10n/zh.json)和单文件上限(1 MiB)。然后用configfile.Capture从已安装插件目录只读地取这些文件,把内容交回 Core,由 Core 校验并逐条回退到清单原文。Snapshot.LocalizationReadFailures()后继续读下一个候选。Load不变,供后端启动、运行等不需要显示文字的读取方使用。core.ReadPluginSettingsState:新增可选的localization请求参数,以及响应里的state.localization(applied、rejected、candidates、maximumBytes、readRequired)。Kernel接口同步。pluginservice.LoadSettingsEditor:增加language参数。包根使用取清单时的那个已安装插件目录,所以一定是绝对路径,也不会读到别的插件。settingswindow):Title是清单原文,原来会在中文按钮下弹出英文确认框。state.Sections[].Title,它现在是译后的文字。workbench):页面仍能加载,所以翻译问题记为“部分拒绝”,而不是失败。app.notification.operation_rejected(WARN),operation=plugin_settings_load。新增两个 reason:localization_unreadable(有候选文件读不了)、invalid_localization(Core 拒绝了文件或其中的条目)。invalid_stored_values改用同一个辅助函数生成字段。pluginsettings/localization_test.go:逐个比对契约localization-cases.json的 13 个用例,覆盖保存回读、读不了的候选。pluginservice安装包测试:读取前后包内文件清单和字节不变。settingswindow/plugin_settings_language_test.go:真实 Core 下切换语言、草稿保护、确认标题。workbench:两种 WARN;TestLogEventsMatchCatalog增加三个 reason 和plugin_settings_load失败。2026-10-21-plugin-settings-surfaces.md新增决策第 9 节(翻译来源、两步读取、只读边界、草稿规则、确认标题、日志、被否方案)。2026-10-14-declarative-plugin-settings.md里“官方插件靠宿主Localizable.strings翻译”的过时说法已改正。declarative-plugin-settings补能力、证据和验证说明(状态仍为 partial/pending)。scripts/i18n/generate-i18n.mjs,单独一个提交):node --test scripts/i18n/test-i18n.mjs两次整套挂起,--test-timeout也没能终止。进程状态显示 gofmt 一直阻塞在读 stdin。spawnSync("gofmt", [], { input })把约 450 KB 的桌面词条源码从 stdin 喂给 gofmt。脱离仓库代码单独复现:本机(Node 24.14.0、Go 1.27.4 的 gofmt)每次喂 450 KB,800 次里有 2 次 gofmt 收不到输入结束、一直等待;把 gofmt 换成cat的 400 次全部正常;改成文件参数的 600 次全部正常。另外,spawnSync会阻塞事件循环,测试框架的超时没有机会触发,违反了 write-stable-tests 的“每个等待都有本地截止时间”。--check仍不改仓库文件;生成结果与原来逐字节相同(--check通过)。本 PR 不改
PINNED_CORE_REVISION:preview 上已固定的 2c1fed1(Core #37,#1903 升级)已包含 #36。不在本 PR 范围内 / Out of scope
l10n/zh-Hans.json(goExecutable、staticcheck、gofumpt、hoverKind 选项等),在 lithe-plugin-go 另提并发预发布。shared/plugins/reference/domains/settings.md里桌面端的支持状态,Core 另提小 PR 更新。类型专属:feat
多平台对齐
platform-specific),理由:范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/declarative-plugin-settings.json:两端证据、验证动作、notes 都已补充;没有整机验收,状态保持 partial / pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/preview HEAD.artifacts/下生成的矩阵视图统一日志系统 / Structured logging
app.notification.operation_rejected,只新增 Token 类型的 reason 值,不新增事件,也没有手写事件 IDoperation_failed;能加载但有部分拒绝时,每种问题最多一条 WARN;只在用户打开设置页时触发,不在高频路径operation和reason两个 Tokenscripts/logging/generate-log-events.mjs、verify-log-usage.mjs已不在本仓库(见 logging 参考页),事件目录在 Core,本 PR 不改目录;改由TestLogEventsMatchCatalog经真实 Core 开启目录校验来编码这些事件界面文案 / i18n
shared/i18n(见 Note 决策第 9 节)node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,没有放宽脚本或扩大豁免名单逻辑归属 / Logic placement
localization-cases.json先于平台接入);桌面端只负责原生只读 I/O 和呈现性能与内存 / Performance and memory
设置 / Settings
插件契约 / Plugin contract
PINNED_CORE_REVISION在 preview 上已是 2c1fed1(Core [Bug] 所有 Maven 项目都提示 "No Maven project detected" — MavenScanPayload 字段名大小写不匹配导致解码失败 #37,包含 适配 macOS 13 并修复应用图标尺寸过大问题 #36),桌面端测试经scripts/desktop/desktop-go.sh读到的就是这份契约plugins.declarative.settingsState是宿主调用 Core 的命令,不是插件可调用的宿主方法发行包与资源 / Bundle and resources
os.Root限定只读地取已安装包内的固定文件,没有新增可写路径;已运行./scripts/desktop/verify/verify-runtime-bundle-immutability.sh无用代码与重构 / Dead code and refactoring
Store.Load仍有后端启动、运行等 4 个生产调用方验证 / Verification
./scripts/desktop/desktop-go.sh vet ./..../scripts/desktop/desktop-go.sh test ./...(rebase 到 7c036b3 后)./scripts/desktop/desktop-go.sh test -race覆盖 core、pluginsettings、pluginservice、settingswindow、workbench(rebase 到 7c036b3 后)test-stability-macos.sh:新增和改动的 l10n 测试(20 项,含 13 个契约用例)./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh --base origin/preview./scripts/agent-notes/verify-agent-notes.shnode scripts/i18n/verify-app-language-localization.mjs、generate-i18n.mjs --checknode --test --test-timeout=60000 scripts/i18n/test-i18n.mjs(每轮另加 240 秒外部上限)cat400 次和文件参数 600 次全部正常verify-platform-feature-matrix.sh、verify-platform-feature-matrix-change.sh origin/preview HEAD./scripts/desktop/verify/verify-runtime-bundle-immutability.sh未能执行的检查和原因:
l10n/文件(Go 插件的中文文件见“不在本 PR 范围内”)。界面行为由无头驱动在真实 Core 下验证。提交前确认 / Final checks
preview创建(已 rebase 到 7c036b3,含 fix(desktop): 保留虚拟源码语言和 URI,取消过期类导航 #1906);目标分支preview.artifacts/等产物,没有凭据和个人路径