仓库页在 Turbo 软导航后整页无法翻译:isRepository 依赖的 analytics-location 是 transient meta
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 44/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- github, javascript
- Lĩnh vực
- frontend, internationalization
Hướng nghiên cứu
Start in main.user.js at detectPageType() and inspect how it uses analytics-location and pathname to identify repository pages. Reproduce the reported Turbo soft-navigation failure and check the proposed fallback against the reserved paths listed in the issue. Done means repository pages translate after soft navigation without misclassifying those reserved routes; the issue also reports vocabulary gaps and character-data updates to investigate.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
问题/建议
环境
- 脚本版本:1.9.4.4-2026-09-27(GitHub 源 / 南大镜像源均复现)
- Tampermonkey 5.x / Edge 142 / Windows 11
现象
从站内点击链接进入仓库页(/<owner>/<repo>)时,页面完全不被翻译,
Console 输出:
[i18n] 路径未匹配任何页面规则
【Debug】首次载入触发, 页面类型为 undefined
直接在地址栏输入 URL 或刷新页面则一切正常。
根因
detectPageType() 中仓库页判定完全依赖 analytics meta:
const isRepository = /\/<user-name>\/<repo-name>/.test(metaLocation);
而该 meta 带 Turbo 临时标记:
<meta name="analytics-location" content="/<user-name>/<repo-name>" data-turbo-transient="true">
data-turbo-transient 的元素在 Turbo 软导航(pjax/turbo:load)时会被移除或延迟更新。
脚本在 URL 变化回调中调用 detectPageType() 时 meta 尚未恢复 → metaLocation === ''
→ isRepository === false → pathname /owner/repo 又不被 rePagePath 匹配
→ pageType === false → State.pageConfig = null → 整页放弃翻译。
这解释了"直达/刷新正常、站内点击不正常"的间歇性表现。
修复建议
isRepository 增加 URL 结构兜底:两段式路径(排除保留字首段)也判定为仓库页,
不再单独依赖该 meta。已实测 16 个典型 URL(仓库/设置/组织/主题/探索/通知/Copilot 等)无误判:
--- a/main.user.js
+++ b/main.user.js
@@ -366,7 +366,15 @@
const isSession = document.body.classList.contains("session-authentication");
const isHomepage = pathname === '/' && site === 'github';
const isProfile = document.body.classList.contains("page-profile") || metaLocation === '/<user-name>';
- const isRepository = /\/<user-name>\/<repo-name>/.test(metaLocation);
+ // 兜底:analytics-location 是 data-turbo-transient 临时 meta,Turbo 软导航时
+ // 可能被移除或更新延迟,导致仓库页被判为未知页面而整页放弃翻译
+ // (症状:站内点击进入 /owner/repo 时 Console 输出"路径未匹配任何页面规则")。
+ // 增加两级 URL 结构兜底:两段式路径(排除保留字首段)也视为仓库页。
+ const reservedFirstSegment = /^\/(?:home|dashboard|feed|copilot|spark|signup|account_verifications|login|logout|sessions?|password_reset|orgs|organizations|explore|topics|notifications|watching|stars|issues|pulls|repos|search|discussions|gist|sponsors|marketplace|apps|codespaces|developer|features|status|education|sitemap|mcp|settings|account|new|redeem|trending|collections|showcases|about|pricing|security|enterprise|customer-stories|site|support|learn|events|tools|edu|campus|git|contact|users|installations|billing|plans)\//i;
+ const isRepository = /\/<user-name>\/<repo-name>/.test(metaLocation)
+ || (site === 'github'
+ && !reservedFirstSegment.test(pathname)
+ && /^\/[^\/@?#]+\/[^\/@?#]+(?:\/|$)/.test(pathname));
完整 patch 文件(含 GlobalNav 空闲条件的重试上限兜底)见附件。
附带反馈:新版 UI 词条缺口(v1.9.4.4 词库)
以下文案在新版仓库页/设置页出现且词库暂未覆盖,实测未命中:
- Latest commit、Folders and files、Repository navigation、Repository files navigation、Open more actions menu
- Cloud agent、Policy insights、Private repository、Report abuse、Global navigation menu
- 两步验证 / 离开仓库对话框的整句提示
另外建议 characterDataPage 白名单加入 repository、repository/tree:
新版仓库侧边栏为骨架屏注水(prc-SkeletonText),水合会以 characterData 突变
覆盖已翻译文本,当前白名单不含仓库页导致英文残留。
复现与定位过程详见控制台日志:【Debug】首次载入触发, 页面类型为 undefined。
### 步骤
## 现象
从站内点击链接进入仓库页(`/<owner>/<repo>`)时,页面完全不被翻译,
Console 输出:
[i18n] 路径未匹配任何页面规则
【Debug】首次载入触发, 页面类型为 undefined
直接在地址栏输入 URL 或刷新页面则一切正常。
### 预期
本应全部翻译
### 实际
很多未翻译
### 附件
_No response_
### 浏览器名称
Microsoft Edge
### 浏览器版本
146.0.3856
### 脚本管理器名称
篡改猴(Tampermonkey)
### 脚本管理器版本
5.4.1
### 插件版本
1.9.3
- Ngôn ngữ chính
- JavaScript
- Star
- 35.1k
- Fork
- 2k
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của maboloshi/github-chinese
-
添加报告文档问题的模板Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
maboloshi/github-chinese#823 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
maboloshi/github-chinese#810 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
项目首页除了顶栏几乎没有翻译Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
maboloshi/github-chinese#803 · 1 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
一些没有翻译完整的页面/句子(大部分是团队的设置界面)Đang mở请求翻译
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
maboloshi/github-chinese#802 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
纯化语种Có thể đã có người làm @PtJade-Ceramic đã nhận 103 ngày trước. Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 35/100
maboloshi/github-chinese#799 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của maboloshi/github-chinese
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
postcss/postcss.org#302 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ImranR98/apps.obtainium.imranr.dev#2000 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
routing: the tray panel's stage stands still with motion reduced while a request is in flightĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
microsoft/monaco-editor#5577 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Ebony-Vinyl/dsh-our-free-model#785 ·
Maintainer thường phản hồi trong vòng 1 ngày