|
15 | 15 | admin: ["ryosukeeeeee"], |
16 | 16 | distractionFreeMode: false, |
17 | 17 | id: decodeURI(window.location.hash.split("?")[0]), |
18 | | - language: "en", |
| 18 | + language: "zh-CN", |
19 | 19 | }); |
20 | 20 |
|
21 | 21 | function normalizeFile(file) { |
|
26 | 26 | return decodeURI(window.location.hash.split("?")[0].replace(/^#/, "") || "/"); |
27 | 27 | } |
28 | 28 |
|
29 | | - function isEnglishRoute() { |
30 | | - return currentRoute() === "/uk" || currentRoute().startsWith("/uk/"); |
31 | | - } |
32 | | - |
33 | 29 | function readingMinutes(markdown) { |
34 | 30 | const clean = markdown |
35 | 31 | .replace(/```[\s\S]*?```/g, " ") |
|
49 | 45 | } |
50 | 46 |
|
51 | 47 | function editUrl(file) { |
52 | | - const sourceFile = normalizeFile(file).replace(/^uk\//, ""); |
53 | | - return `${REPOSITORY}/edit/master/docs/${encodedFilePath(sourceFile)}`; |
| 48 | + return `${REPOSITORY}/edit/master/docs/${encodedFilePath(file)}`; |
54 | 49 | } |
55 | 50 |
|
56 | 51 | function articleChrome() { |
57 | | - const english = isEnglishRoute(); |
58 | 52 | const minutes = readingMinutes(activeMarkdown); |
59 | | - const readingLabel = english ? `${minutes} min read` : `约 ${minutes} 分钟阅读`; |
60 | | - const updateLabel = english ? "Updated: fetching…" : "更新于:正在获取…"; |
61 | | - const editLabel = english ? "Edit this page on GitHub" : "在 GitHub 上编辑此页"; |
62 | | - const discussionTitle = english ? "Community discussion" : "社区讨论"; |
63 | | - const discussionText = english |
64 | | - ? "Sign in with GitHub to join the discussion for this page." |
65 | | - : "使用 GitHub 登录,参与当前页面的讨论。"; |
66 | | - const chineseRoute = currentRoute().replace(/^\/uk(?=\/|$)/, "") || "/"; |
67 | | - const translationNotice = english |
68 | | - ? ` |
69 | | - <aside class="translation-notice" aria-label="Translation notice"> |
70 | | - <strong>Machine-translated from Chinese.</strong> |
71 | | - <span>The Chinese page is authoritative.</span> |
72 | | - <a href="#${chineseRoute}">Read the source</a> |
73 | | - </aside> |
74 | | - ` |
75 | | - : ""; |
76 | 53 |
|
77 | 54 | return { |
78 | 55 | before: ` |
79 | | - <div class="article-meta" aria-label="Page information"> |
80 | | - <span class="article-meta__item article-reading-time">${readingLabel}</span> |
| 56 | + <div class="article-meta" aria-label="页面信息"> |
| 57 | + <span class="article-meta__item article-reading-time">约 ${minutes} 分钟阅读</span> |
81 | 58 | <span class="article-meta__separator" aria-hidden="true"></span> |
82 | | - <span class="article-meta__item article-updated" data-file="${normalizeFile(activeFile)}">${updateLabel}</span> |
| 59 | + <span class="article-meta__item article-updated" data-file="${normalizeFile(activeFile)}">更新于:正在获取…</span> |
83 | 60 | </div> |
84 | | - ${translationNotice} |
85 | 61 | `, |
86 | 62 | after: ` |
87 | 63 | <footer class="article-footer"> |
88 | | - <p>${english ? "Found a problem or an outdated step?" : "发现错误或过时步骤?"}</p> |
89 | | - <a href="${editUrl(activeFile)}" target="_blank" rel="noopener noreferrer">${editLabel} <span aria-hidden="true">↗</span></a> |
| 64 | + <p>发现错误或过时步骤?</p> |
| 65 | + <a href="${editUrl(activeFile)}" target="_blank" rel="noopener noreferrer">在 GitHub 上编辑此页 <span aria-hidden="true">↗</span></a> |
90 | 66 | </footer> |
91 | | - <nav class="page-navigation" aria-label="${english ? "Previous and next pages" : "上一篇与下一篇"}"></nav> |
| 67 | + <nav class="page-navigation" aria-label="上一篇与下一篇"></nav> |
92 | 68 | <section class="comments-section" aria-labelledby="comments-title"> |
93 | 69 | <div class="comments-heading"> |
94 | | - <p class="eyebrow">${english ? "GitHub Comments" : "GitHub Comments"}</p> |
95 | | - <h2 id="comments-title">${discussionTitle}</h2> |
96 | | - <p>${discussionText}</p> |
| 70 | + <p class="eyebrow">GitHub 评论</p> |
| 71 | + <h2 id="comments-title">社区讨论</h2> |
| 72 | + <p>使用 GitHub 登录,参与当前页面的讨论。</p> |
97 | 73 | </div> |
98 | 74 | <div id="gitalk-container" aria-live="polite"></div> |
99 | 75 | </section> |
|
134 | 110 | if (!element) return; |
135 | 111 |
|
136 | 112 | const file = element.dataset.file; |
137 | | - const english = isEnglishRoute(); |
138 | 113 | fetchLastUpdated(file) |
139 | 114 | .then((date) => { |
140 | | - element.textContent = english ? `Updated: ${date}` : `更新于:${date}`; |
| 115 | + element.textContent = `更新于:${date}`; |
141 | 116 | }) |
142 | 117 | .catch(() => { |
143 | | - element.textContent = english ? "Update date unavailable" : "更新日期暂不可用"; |
| 118 | + element.textContent = "更新日期暂不可用"; |
144 | 119 | }); |
145 | 120 | } |
146 | 121 |
|
|
151 | 126 | const button = document.createElement("button"); |
152 | 127 | button.className = "copy-code"; |
153 | 128 | button.type = "button"; |
154 | | - button.textContent = isEnglishRoute() ? "Copy" : "复制"; |
155 | | - button.setAttribute("aria-label", isEnglishRoute() ? "Copy code" : "复制代码"); |
| 129 | + button.textContent = "复制"; |
| 130 | + button.setAttribute("aria-label", "复制代码"); |
156 | 131 | button.addEventListener("click", async () => { |
157 | 132 | const code = block.querySelector("code")?.textContent || ""; |
158 | 133 | try { |
159 | 134 | await navigator.clipboard.writeText(code); |
160 | | - button.textContent = isEnglishRoute() ? "Copied" : "已复制"; |
| 135 | + button.textContent = "已复制"; |
161 | 136 | } catch { |
162 | | - button.textContent = isEnglishRoute() ? "Failed" : "复制失败"; |
| 137 | + button.textContent = "复制失败"; |
163 | 138 | } |
164 | 139 | window.setTimeout(() => { |
165 | | - button.textContent = isEnglishRoute() ? "Copy" : "复制"; |
| 140 | + button.textContent = "复制"; |
166 | 141 | }, 1600); |
167 | 142 | }); |
168 | 143 | block.append(button); |
|
176 | 151 | wrapper.className = "table-scroll"; |
177 | 152 | wrapper.tabIndex = 0; |
178 | 153 | wrapper.setAttribute("role", "region"); |
179 | | - wrapper.setAttribute("aria-label", isEnglishRoute() ? "Scrollable table" : "可横向滚动的表格"); |
| 154 | + wrapper.setAttribute("aria-label", "可横向滚动的表格"); |
180 | 155 | table.before(wrapper); |
181 | 156 | wrapper.append(table); |
182 | 157 | }); |
|
205 | 180 | }); |
206 | 181 | if (currentIndex < 0) return; |
207 | 182 |
|
208 | | - const english = isEnglishRoute(); |
209 | 183 | const items = [ |
210 | | - { source: links[currentIndex - 1], className: "previous", label: english ? "Previous" : "上一篇", arrow: "←" }, |
211 | | - { source: links[currentIndex + 1], className: "next", label: english ? "Next" : "下一篇", arrow: "→" }, |
| 184 | + { source: links[currentIndex - 1], className: "previous", label: "上一篇", arrow: "←" }, |
| 185 | + { source: links[currentIndex + 1], className: "next", label: "下一篇", arrow: "→" }, |
212 | 186 | ]; |
213 | 187 |
|
214 | 188 | for (const item of items) { |
|
230 | 204 | const container = document.getElementById("gitalk-container"); |
231 | 205 | if (!container) return; |
232 | 206 | if (typeof window.Gitalk !== "function") { |
233 | | - container.textContent = isEnglishRoute() |
234 | | - ? "Comments are temporarily unavailable." |
235 | | - : "评论暂时无法加载。"; |
| 207 | + container.textContent = "评论暂时无法加载。"; |
236 | 208 | return; |
237 | 209 | } |
238 | 210 |
|
239 | 211 | try { |
240 | 212 | const gitalk = new window.Gitalk(commentOptions()); |
241 | 213 | gitalk.render("gitalk-container"); |
242 | 214 | } catch { |
243 | | - container.textContent = isEnglishRoute() |
244 | | - ? "Comments are temporarily unavailable." |
245 | | - : "评论暂时无法加载。"; |
246 | | - } |
247 | | - } |
248 | | - |
249 | | - function updateLanguageControls() { |
250 | | - const english = isEnglishRoute(); |
251 | | - const route = currentRoute(); |
252 | | - const languageLink = document.querySelector(".language-switch"); |
253 | | - |
254 | | - document.documentElement.lang = english ? "en" : "zh-CN"; |
255 | | - if (languageLink) { |
256 | | - const target = english |
257 | | - ? route.replace(/^\/uk(?=\/|$)/, "") || "/" |
258 | | - : `/uk${route === "/" ? "/" : route}`; |
259 | | - languageLink.href = `#${target}`; |
260 | | - languageLink.textContent = english ? "中" : "EN"; |
261 | | - languageLink.setAttribute("aria-label", english ? "切换到中文" : "Switch to English"); |
| 215 | + container.textContent = "评论暂时无法加载。"; |
262 | 216 | } |
263 | 217 | } |
264 | 218 |
|
|
342 | 296 | }); |
343 | 297 |
|
344 | 298 | hook.doneEach(() => { |
345 | | - updateLanguageControls(); |
346 | 299 | updateLastModified(); |
347 | 300 | enhanceCodeBlocks(); |
348 | 301 | enhanceTables(); |
|
0 commit comments