Skip to content

Commit

Permalink
docs(i18n): add i18n support for vitepress (#49)
Browse files Browse the repository at this point in the history
* chore(docs): add logo for docs

* docs(i18n): add i18n support
  • Loading branch information
fu050409 authored Jul 17, 2024
1 parent fa2c5b1 commit 1e49725
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 32 deletions.
4 changes: 3 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"src/assets/**",
"public/**",
"dist/**",
"pnpm-lock.yaml"
"pnpm-lock.yaml",
// Vitepress files
"docs/.vitepress/**"
]
}
37 changes: 6 additions & 31 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,12 @@
import { defineConfig } from 'vitepress';
import { shared } from './shared';
import { zh } from './zh';
import { en } from './en';

// https://vitepress.dev/reference/site-config
export default defineConfig({
lang: 'en-US',
title: 'Grassator',
description: 'Secure, modern and fast multi-process downloader',
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
logo: '/logo.png',

nav: [{ text: 'Home', link: '/' }],

sidebar: [],

socialLinks: [
{ icon: 'github', link: 'https://github.com/noctisynth/Grassator' },
],

footer: {
message:
'Released under the <a href="https://github.com/noctisynth/Grassator/blob/main/LICENSE-MIT">MIT License</a> and <a href="https://github.com/noctisynth/Grassator/blob/main/LICENSE-AGPL">AGPLv3 License</a>.',
copyright:
'Copyright © 2011-present <a href="https://github.com/noctisynth">Noctisynth, Inc.</a>',
},
},
...shared,
locales: {
root: {
label: 'English',
lang: 'en-US',
},
zh: {
label: '简体中文',
lang: 'zh-CN',
},
root: { label: 'English', ...en },
zh: { label: '简体中文', ...zh },
},
});
19 changes: 19 additions & 0 deletions docs/.vitepress/en.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig, type DefaultTheme } from 'vitepress';

export const en = defineConfig({
lang: 'en-US',
description: 'Secure, modern and fast multi-process downloader',

themeConfig: {
nav: [{ text: 'Home', link: '/' }],

sidebar: [],

footer: {
message:
'Released under the <a href="https://github.com/noctisynth/Grassator/blob/main/LICENSE-MIT">MIT License</a> and <a href="https://github.com/noctisynth/Grassator/blob/main/LICENSE-AGPL">AGPLv3 License</a>.',
copyright:
'Copyright © 2011-present <a href="https://github.com/noctisynth">Noctisynth, Inc.</a>',
},
},
});
35 changes: 35 additions & 0 deletions docs/.vitepress/shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { defineConfig } from 'vitepress';
import { search as zhSearch } from './zh';

export const shared = defineConfig({
title: 'Grassator',

lastUpdated: true,
cleanUrls: true,
metaChunk: true,

sitemap: {
hostname: 'https://grassator.noctisynth.org',
},

themeConfig: {
logo: {
dark: '/icon.png',
light: '/light.ico',
},

socialLinks: [
{ icon: 'github', link: 'https://github.com/noctisynth/Grassator' },
],

search: {
provider: 'algolia',
options: {
appId: '9RCKXREJL8',
apiKey: 'fed8c71cf1f3731cd91d99fb8b5bc289',
indexName: 'grassator',
locales: { ...zhSearch },
},
},
},
});
90 changes: 90 additions & 0 deletions docs/.vitepress/zh.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { defineConfig, type DefaultTheme } from 'vitepress';

export const zh = defineConfig({
lang: 'zh-Hans',
description: '由 Vite 和 Vue 驱动的静态站点生成器',

themeConfig: {
nav: [{ text: '主页', link: '/zh/' }],

sidebar: [],

editLink: {
pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path',
text: '在 GitHub 上编辑此页面',
},

footer: {
message: '基于 MIT 及 AGPLv3 许可发布',
copyright: `版权所有 © 2011-present <a href="https://github.com/noctisynth">夜莲组织</a>`,
},

docFooter: {
prev: '上一页',
next: '下一页',
},

outline: {
label: '页面导航',
},

lastUpdated: {
text: '最后更新于',
formatOptions: {
dateStyle: 'short',
timeStyle: 'medium',
},
},

langMenuLabel: '多语言',
returnToTopLabel: '回到顶部',
sidebarMenuLabel: '菜单',
darkModeSwitchLabel: '主题',
lightModeSwitchTitle: '切换到浅色模式',
darkModeSwitchTitle: '切换到深色模式',
},
});

export const search: DefaultTheme.AlgoliaSearchOptions['locales'] = {
zh: {
placeholder: '搜索文档',
translations: {
button: {
buttonText: '搜索文档',
buttonAriaLabel: '搜索文档',
},
modal: {
searchBox: {
resetButtonTitle: '清除查询条件',
resetButtonAriaLabel: '清除查询条件',
cancelButtonText: '取消',
cancelButtonAriaLabel: '取消',
},
startScreen: {
recentSearchesTitle: '搜索历史',
noRecentSearchesText: '没有搜索历史',
saveRecentSearchButtonTitle: '保存至搜索历史',
removeRecentSearchButtonTitle: '从搜索历史中移除',
favoriteSearchesTitle: '收藏',
removeFavoriteSearchButtonTitle: '从收藏中移除',
},
errorScreen: {
titleText: '无法获取结果',
helpText: '你可能需要检查你的网络连接',
},
footer: {
selectText: '选择',
navigateText: '切换',
closeText: '关闭',
searchByText: '搜索提供者',
},
noResultsScreen: {
noResultsText: '无法找到相关结果',
suggestedQueryText: '你可以尝试查询',
reportMissingResultsText: '你认为该查询应该有结果?',
reportMissingResultsLinkText: '点击反馈',
},
},
},
},
};
Binary file added docs/public/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/light.ico
Binary file not shown.

0 comments on commit 1e49725

Please sign in to comment.