🌐 Cover chrome.i18n messages.json and Monaco editor langs for pt-BR / tr-TR#1605
Open
CodFrm wants to merge 3 commits into
Open
🌐 Cover chrome.i18n messages.json and Monaco editor langs for pt-BR / tr-TR#1605CodFrm wants to merge 3 commits into
CodFrm wants to merge 3 commits into
Conversation
PR #1587 的 pt-BR 翻译遗漏了 src/assets/_locales/(商店/清单文案)与 src/pkg/utils/monaco-editor/langs.ts(编辑器 metadata 提示与快速修复文案, 缺失时回退英文)。补齐两处,并新增语言覆盖守卫测试。
土耳其语翻译当时同样遗漏了 editorLangs(_locales/tr 已存在)。补齐后 将守卫测试收紧为 editorLangs 与注册的 UI 语言一一对应。
langs.ts 已含 9 种语言约 1300 行,拆为 langs/<locale>.ts + index.ts, 导入路径 ./langs 不变。拆分为纯机械搬移,已用临时深度对比测试验证 拆分前后 editorLangs 内容完全一致。
This comment was marked as outdated.
This comment was marked as outdated.
CodFrm
marked this pull request as draft
July 17, 2026 18:16
This comment was marked as outdated.
This comment was marked as outdated.
cyfung1031
added a commit
to cyfung1031/scriptcat
that referenced
this pull request
Jul 17, 2026
用 PR scriptscat#1605 实测时发现:check-i18n.mjs 硬编码了单文件 src/pkg/utils/monaco-editor/langs.ts 路径,一旦该文件被拆分为 langs/<locale>.ts + langs/index.ts(如 scriptscat#1605 所做),检查会误报 "文件缺失"。改为先探测 langs/index.ts 是否存在,再退回单文件路径;并将 key 展开逻辑改为 按模块解析(parseModule/flattenNode),支持跨文件解析 import 绑定(如 index.ts 里 "pt-BR": ptBR 指向 ./pt-BR.ts 的 default export)与同文件 shorthand 属性 (如 pt-BR.ts 内的 grantValuePrompts,)。 已用 scriptscat#1605 的实际分支验证:新结构下 0 误报,人为在拆分后的 pt-BR.ts 中删除顶层 key 与 grantValuePrompts 子 key 均能正确报出具体路径。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Collaborator
|
用 #1606 里新增的机械检查脚本( 具体覆盖到的点:
一个说明:本 PR 把 另外发现本 PR 新增的 |
Collaborator
cyfung1031
marked this pull request as ready for review
July 17, 2026 18:39
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.
Checklist / 检查清单
背景
PR #1587 的 pt-BR 翻译遗漏了两处本地化面(见 评论反馈):
src/assets/_locales/下没有pt_BR/messages.json(chrome.i18n 的扩展名称/商店描述),其余 8 个语言都有;editorLangs没有pt-BR条目(编辑器 metadata 悬浮提示、@grant权限说明、快速修复文案),缺失时静默回退英文。排查中发现 tr-TR 存在同类缺口:
_locales/tr已有,但editorLangs同样缺失土耳其语条目,一并补齐。本次改动
src/assets/_locales/pt_BR/messages.json,商店描述沿用 pt-BR 语言包既有措辞(gerenciador de scripts de usuário)。editorLangs新增pt-BR、tr-TR完整条目(各约 90 条),分别遵循docs/references/terminology-pt-BR.md与terminology-tr-TR.md的术语规范(如 pt-BR 用entre origens而非origem cruzada、Aba、link de afiliado;tr-TR 用betik、Sekme、保留GM API与@标识符)。langs.ts单文件已含 9 种语言约 1300 行,按语言拆分为src/pkg/utils/monaco-editor/langs/<locale>.ts+index.ts,导入路径./langs不变。拆分为纯机械搬移,已用临时深度对比测试验证拆分前后editorLangs内容完全一致。src/pkg/utils/monaco-editor/langs.test.ts:editorLangs与src/locales/注册的 UI 语言一一对应,且各条目键结构与 en-US 一致;src/locales/chrome-locales.test.ts:每个 UI 语言都有对应的_locales目录,且各messages.json键与en一致。已知限制
对其余翻译面做了完整盘点,运行时侧无其他缺口(各 locale 的
*.json键与 en-US 完全对齐、语言下拉框与相对时间格式化均为动态派生、chrome.i18n.getMessage无代码调用)。唯一剩余缺口在文档层:本地化 README 仅有 zh-CN / zh-TW / ja / RU 四种,de / vi / tr / pt-BR 尚无,留待后续单独处理。建议审查重点
crontab、antifeature、unwrap等长文案。关联
验证
editorLangs与拆分前(git show HEAD版本)深度对比,完全一致后移除。pnpm lint:prettier / tsc / eslint 全部通过。npx vitest run(与 lint 顺序执行):306 文件 / 3370 用例全部通过。此前并行跑 lint 与测试时曾出现偶发超时失败,失败集在多次运行间完全不同且单独重跑全过,确认为满载并发下 340ms 超时抖动,与本次改动无关。