From 65b2b7561a185be29ff7f773bf9432dc3c4da2e4 Mon Sep 17 00:00:00 2001 From: 李瑞丰 Date: Tue, 18 Jul 2023 05:28:55 +0800 Subject: i18n(zh-cn): Add Simplified Chinese language support (#353) Co-authored-by: Chris Swithinbank --- .changeset/nasty-pigs-buy.md | 5 +++++ docs/src/content/docs/guides/i18n.mdx | 2 +- packages/starlight/translations/index.ts | 3 ++- packages/starlight/translations/zh.json | 23 +++++++++++++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 .changeset/nasty-pigs-buy.md create mode 100644 packages/starlight/translations/zh.json diff --git a/.changeset/nasty-pigs-buy.md b/.changeset/nasty-pigs-buy.md new file mode 100644 index 00000000..35a23c95 --- /dev/null +++ b/.changeset/nasty-pigs-buy.md @@ -0,0 +1,5 @@ +--- +"@astrojs/starlight": patch +--- + +Add Simplified Chinese language support diff --git a/docs/src/content/docs/guides/i18n.mdx b/docs/src/content/docs/guides/i18n.mdx index c1b1ab1f..7a6fb2e2 100644 --- a/docs/src/content/docs/guides/i18n.mdx +++ b/docs/src/content/docs/guides/i18n.mdx @@ -143,7 +143,7 @@ If a translation is not yet available for a language, Starlight will show reader In addition to hosting translated content files, Starlight allows you to translate the default UI strings (e.g. the "On this page" heading in the table of contents) so that your readers can experience your site entirely in the selected language. -English, Czech, French, German, Italian, Japanese, Portuguese, Dutch, Danish, Spanish, Turkish, Arabic, and Norwegian translated UI strings are provided out of the box, and we welcome [contributions to add more default languages](https://github.com/withastro/starlight/blob/main/CONTRIBUTING.md). +English, Czech, French, German, Italian, Japanese, Portuguese, Dutch, Danish, Spanish, Turkish, Arabic, Norwegian, and Simplified Chinese translated UI strings are provided out of the box, and we welcome [contributions to add more default languages](https://github.com/withastro/starlight/blob/main/CONTRIBUTING.md). You can provide translations for additional languages you support — or override our default labels — via the `i18n` data collection. diff --git a/packages/starlight/translations/index.ts b/packages/starlight/translations/index.ts index 0e51ea5e..2f4a70a2 100644 --- a/packages/starlight/translations/index.ts +++ b/packages/starlight/translations/index.ts @@ -12,11 +12,12 @@ import da from './da.json'; import tr from './tr.json'; import ar from './ar.json'; import nb from './nb.json'; +import zh from './zh.json'; const { parse } = builtinI18nSchema(); export default Object.fromEntries( - Object.entries({ cs, en, es, de, ja, pt, fr, it, nl, da, tr, ar, nb }).map(([key, dict]) => [ + Object.entries({ cs, en, es, de, ja, pt, fr, it, nl, da, tr, ar, nb, zh }).map(([key, dict]) => [ key, parse(dict), ]) diff --git a/packages/starlight/translations/zh.json b/packages/starlight/translations/zh.json new file mode 100644 index 00000000..6a57671d --- /dev/null +++ b/packages/starlight/translations/zh.json @@ -0,0 +1,23 @@ +{ + "skipLink.label": "跳转到内容", + "search.label": "搜索", + "search.shortcutLabel": "(按 / 进行搜索)", + "search.cancelLabel": "取消", + "search.devWarning": "搜索仅适用于生产版本。\n尝试构建并预览网站以在本地测试。", + "themeSelect.accessibleLabel": "选择主题", + "themeSelect.dark": "深色", + "themeSelect.light": "浅色", + "themeSelect.auto": "自动", + "languageSelect.accessibleLabel": "选择语言", + "menuButton.accessibleLabel": "菜单", + "sidebarNav.accessibleLabel": "主要", + "tableOfContents.onThisPage": "本页", + "tableOfContents.overview": "概述", + "i18n.untranslatedContent": "此内容尚不支持你的语言。", + "page.editLink": "编辑此页", + "page.lastUpdated": "最近更新:", + "page.previousLink": "上一页", + "page.nextLink": "下一页", + "404.text": "页面未找到。检查 URL 或尝试使用搜索栏。" +} + -- cgit