diff --git a/templates/default(zh-cn)/token.json b/templates/default(zh-cn)/token.json
index d208971bcf9..42e1330a7a1 100644
--- a/templates/default(zh-cn)/token.json
+++ b/templates/default(zh-cn)/token.json
@@ -11,7 +11,7 @@
"eventsInSubtitle": "事件",
"operatorsInSubtitle": "运算符",
"eiisInSubtitle": "显示接口实现",
- "improveThisDoc": "改善此文档",
+ "improveThisDoc": "编辑本文",
"viewSource": "查看源代码",
"inheritance": "继承",
"inheritedMembers": "继承成员",
@@ -42,12 +42,20 @@
"important": "重要事项",
"caution": "小心",
"tocToggleButton": "显示/隐藏目录",
- "tocFilter": "按标题筛选...",
+ "tocFilter": "按标题筛选",
"search": "搜索",
"searchResults": "搜索结果",
+ "searchResultsCount": "找到{count}个“{query}”的搜索结果",
+ "searchNoResults": "没有找到“{query}”的搜索结果",
"pageFirst": "首页",
"pagePrev": "上一页",
"pageNext": "下一页",
"pageLast": "尾页",
- "inThisArticle": "本文内容"
+ "inThisArticle": "本文内容",
+ "nextArticle": "下一篇",
+ "prevArticle": "上一篇",
+ "themeLight": "白天",
+ "themeDark": "夜晚",
+ "themeAuto": "自动",
+ "copy": "复制"
}
diff --git a/templates/default/token.json b/templates/default/token.json
index c0fc6c3dda2..6f2c71fd7f5 100644
--- a/templates/default/token.json
+++ b/templates/default/token.json
@@ -16,7 +16,7 @@
"variablesInSubtitle": "Variables",
"typeAliasesInSubtitle": "Type Aliases",
"membersInSubtitle": "Members",
- "improveThisDoc": "Improve this Doc",
+ "improveThisDoc": "Edit this page",
"viewSource": "View Source",
"inheritance": "Inheritance",
"derived": "Derived",
@@ -51,13 +51,21 @@
"important": "Important",
"caution": "Caution",
"tocToggleButton": "Show / Hide Table of Contents",
- "tocFilter": "Enter here to filter...",
+ "tocFilter": "Filter by title",
"search": "Search",
"searchResults": "Search Results for",
+ "searchResultsCount": "{count} results for \"{query}\"",
+ "searchNoResults": "No results for \"{query}\"",
"pageFirst": "First",
"pagePrev": "Previous",
"pageNext": "Next",
"pageLast": "Last",
"inThisArticle": "In This Article",
- "backToTop": "Back to top"
+ "nextArticle": "Next",
+ "prevArticle": "Previous",
+ "backToTop": "Back to top",
+ "themeLight": "Light",
+ "themeDark": "Dark",
+ "themeAuto": "Auto",
+ "copy": "Copy"
}
diff --git a/templates/modern/layout/_master.tmpl b/templates/modern/layout/_master.tmpl
index acb86cc9f3f..ce60ba3adb3 100644
--- a/templates/modern/layout/_master.tmpl
+++ b/templates/modern/layout/_master.tmpl
@@ -25,6 +25,16 @@
{{#_disableNewTab}}{{/_disableNewTab}}
{{#_disableTocFilter}}{{/_disableTocFilter}}
{{#docurl}}{{/docurl}}
+
+
+
+
+
+
+
+
+
+
{{/redirect_url}}
@@ -106,10 +116,10 @@
{{^_disableContribution}}
{{/_disableContribution}}
diff --git a/templates/modern/src/helper.ts b/templates/modern/src/helper.ts
index 78e95f79865..9c64c2ac8a8 100644
--- a/templates/modern/src/helper.ts
+++ b/templates/modern/src/helper.ts
@@ -10,6 +10,20 @@ export function meta(name: string): string {
return (document.querySelector(`meta[name="${name}"]`) as HTMLMetaElement)?.content
}
+/**
+ * Gets the localized text.
+ * @param id key in token.json
+ */
+export function loc(id: string, args?: any): string {
+ let result = meta(`loc:${id}`) || id
+ if (args) {
+ for (const key in args) {
+ result = result.replace(`{${key}}`, args[key])
+ }
+ }
+ return result
+}
+
/**
* Add into long word.
*/
diff --git a/templates/modern/src/markdown.ts b/templates/modern/src/markdown.ts
index 1ff54830637..4dfc0e1f565 100644
--- a/templates/modern/src/markdown.ts
+++ b/templates/modern/src/markdown.ts
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-import { breakWord, meta } from './helper'
+import { breakWord, meta, loc } from './helper'
import AnchorJs from 'anchor-js'
import { html, render } from 'lit-html'
import { getTheme } from './theme'
@@ -186,7 +186,7 @@ function renderCodeCopy() {
function renderCore() {
const dom = copied
? html``
- : html``
+ : html``
render(dom, code.parentElement)
async function copy(e) {
diff --git a/templates/modern/src/nav.ts b/templates/modern/src/nav.ts
index 45ca72ba75b..4fc6267ab4a 100644
--- a/templates/modern/src/nav.ts
+++ b/templates/modern/src/nav.ts
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
import { render, html, TemplateResult } from 'lit-html'
-import { breakWordLit, meta, isExternalHref } from './helper'
+import { breakWordLit, meta, isExternalHref, loc } from './helper'
import { themePicker } from './theme'
import { TocNode } from './toc'
@@ -105,7 +105,7 @@ function inThisArticleForConceptual() {
const headings = document.querySelectorAll('article h2')
if (headings.length > 0) {
return html`
- In this article
+ ${loc('inThisArticle')}
`
}
}
@@ -116,7 +116,7 @@ function inThisArticleForManagedReference(): TemplateResult {
if (headings.length > 0) {
return html`
- In this article
+ ${loc('inThisArticle')}
${headings.map(h => {
return h.tagName === 'H2'
? html`${breakWordLit(h.innerText)}
`
diff --git a/templates/modern/src/search.ts b/templates/modern/src/search.ts
index acf84cb8479..43ba3cce7a5 100644
--- a/templates/modern/src/search.ts
+++ b/templates/modern/src/search.ts
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-import { meta } from './helper'
+import { loc, meta } from './helper'
import { html, render, TemplateResult } from 'lit-html'
import { classMap } from 'lit-html/directives/class-map.js'
@@ -84,14 +84,14 @@ export function enableSearch() {
function renderPage(page: number): TemplateResult {
if (hits.length === 0) {
- return html`No results for "${query}"
`
+ return html`${loc('searchNoResults', { query })}
`
}
const start = page * numPerPage
const curHits = hits.slice(start, start + numPerPage)
const items = html`
- ${hits.length} results for "${query}"
+ ${loc("searchResultsCount", { count: hits.length, query })}
${curHits.map(hit => {
const currentUrl = window.location.href
const itemRawHref = relativeUrlToAbsoluteUrl(currentUrl, relHref + hit.href)
diff --git a/templates/modern/src/theme.ts b/templates/modern/src/theme.ts
index ea1ec88f238..e82e244d217 100644
--- a/templates/modern/src/theme.ts
+++ b/templates/modern/src/theme.ts
@@ -3,6 +3,7 @@
import { html } from 'lit-html'
import { Theme } from './options'
+import { loc } from './helper'
function setTheme(theme: Theme) {
localStorage.setItem('theme', theme)
@@ -35,9 +36,9 @@ export function themePicker(refresh: () => void) {
`
diff --git a/templates/modern/src/toc.ts b/templates/modern/src/toc.ts
index 7f8d993007a..1bd98e22671 100644
--- a/templates/modern/src/toc.ts
+++ b/templates/modern/src/toc.ts
@@ -3,7 +3,7 @@
import { TemplateResult, html, render } from 'lit-html'
import { classMap } from 'lit-html/directives/class-map.js'
-import { breakWordLit, meta, isExternalHref } from './helper'
+import { breakWordLit, meta, isExternalHref, loc } from './helper'
export type TocNode = {
name: string
@@ -132,7 +132,7 @@ export async function renderToc(): Promise {
: html`
`
function filterToc(e: Event) {
@@ -143,7 +143,7 @@ export async function renderToc(): Promise {
}
function renderNoFilterResult(): TemplateResult {
- return tocFilter === '' ? null : html`No results for "${tocFilter}"
`
+ return tocFilter === '' ? null : html`${loc('searchNoResults', { query: tocFilter })}
`
}
function normalizeUrlPath(url: { pathname: string }): string {
@@ -165,8 +165,8 @@ function renderNextArticle(items: TocNode[], node: TocNode) {
return
}
- const prevButton = prev ? html`` : null
- const nextButton = next ? html`` : null
+ const prevButton = prev ? html`` : null
+ const nextButton = next ? html`` : null
render(html`${prevButton} ${nextButton}`, nextArticle)