diff --git a/astro.config.ts b/astro.config.ts index 8834a22..d811caf 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -34,26 +34,39 @@ export default defineConfig({ sidebar: [ { label: "Core Concepts", + translations: { 'zh-CN': '核心概念' }, items: [ // Each item here is one entry in the navigation menu. - { label: "Why Volar?", link: "/core-concepts/why-volar" }, - { label: "Embedded Languages", link: "/core-concepts/embedded-languages" }, + { label: "Why Volar?", link: "/core-concepts/why-volar", translations: { 'zh-CN': '为什么选择 Volar?' } }, + { label: "Embedded Languages", link: "/core-concepts/embedded-languages", translations: { 'zh-CN': '嵌入式语言' } }, { label: "Volar Labs", link: "/core-concepts/volar-labs" }, ], // TODO: Use `autogenerate` once it allows you to order the sidebar }, { label: "Guides", + translations: { 'zh-CN': '指南' }, items: [ - { label: "Your First Volar Language Server", link: "/guides/first-server" }, - { label: "File Structure", link: "/guides/file-structure" }, + { label: "Your First Volar Language Server", link: "/guides/first-server", translations: { 'zh-CN': '你的第一个 Volar 语言服务器' } }, + { label: "File Structure", link: "/guides/file-structure", translations: { 'zh-CN': '文件结构' } }, ], }, { label: "Reference", + translations: { 'zh-CN': '参考' }, autogenerate: { directory: "reference" }, }, ], + locales: { + root: { + label: 'English', + lang: 'en-US', + }, + 'zh-cn': { + label: '简体中文', + lang: 'zh-CN', + } + } }), ], }); diff --git a/src/content/docs/core-concepts/volar-labs-1.png b/src/assets/volar-labs-1.png similarity index 100% rename from src/content/docs/core-concepts/volar-labs-1.png rename to src/assets/volar-labs-1.png diff --git a/src/components/starlight/SiteTitle.astro b/src/components/starlight/SiteTitle.astro index e6612ce..e546d30 100644 --- a/src/components/starlight/SiteTitle.astro +++ b/src/components/starlight/SiteTitle.astro @@ -3,9 +3,19 @@ import type { Props } from "@astrojs/starlight/props"; import AstrolightSiteTitle from "@astrojs/starlight/components/SiteTitle.astro"; const menuItems = [ - { name: "Docs", href: "/core-concepts/why-volar" }, - { name: "Blog", href: "/blog" }, + { + name: { 'en-US': "Docs", 'zh-CN': '文档' }, + id: 'docs', + href: { 'en-US': "/core-concepts/why-volar", 'zh-CN': "/zh-cn/core-concepts/why-volar" } + }, + { + name: { 'en-US': "Blog", 'zh-CN': '博客' }, + id: 'blog', + href: { 'en-US': "/blog", 'zh-CN': "/blog" } + }, ]; +type DefinedI18nName = keyof typeof menuItems[number]['name'] +type DefinedHref = keyof typeof menuItems[number]['href']; function pathsMatch(pathA: string, pathB: string): boolean { return pathB.includes(pathA); @@ -21,14 +31,14 @@ function pathsMatch(pathA: string, pathB: string): boolean { { menuItems.map((menuItem) => ( - {menuItem.name} + {menuItem.name[Astro.currentLocale as DefinedI18nName] || menuItem.name['en-US']} )) } diff --git a/src/content/docs/core-concepts/volar-labs.mdx b/src/content/docs/core-concepts/volar-labs.mdx index 31c76cd..d1c4440 100644 --- a/src/content/docs/core-concepts/volar-labs.mdx +++ b/src/content/docs/core-concepts/volar-labs.mdx @@ -9,7 +9,7 @@ Those pesky times where your mappings are off by one, or you're not sure what fi Volar Labs is a VS Code extension to help you debug your Volar-powered language server and client. **It's the editor tooling for the people who make the editor tooling.** -![A screenshot of Volar Labs, showing the mappings between the different parts of a file being inspected](./volar-labs-1.png) +![A screenshot of Volar Labs, showing the mappings between the different parts of a file being inspected](../../../assets/volar-labs-1.png) ## Installation diff --git a/src/content/docs/zh-cn/core-concepts/embedded-languages.mdx b/src/content/docs/zh-cn/core-concepts/embedded-languages.mdx new file mode 100644 index 0000000..d28bd11 --- /dev/null +++ b/src/content/docs/zh-cn/core-concepts/embedded-languages.mdx @@ -0,0 +1,12 @@ +--- +title: 嵌入式语言 +description: VolarJS 对嵌入式语言提供了顶级支持,并可以大大简化在文件不同部分之间实现编辑功能所需的映射。 +--- + +如今,许多编程语言都是由其他编程语言组成的。最著名的例子是 HTML, 在其中你会发现 JavaScript 和 CSS 分别位于 `