Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: multi-language support #58

Merged
merged 7 commits into from
Jan 11, 2020
Merged

Conversation

PeachScript
Copy link
Member

@PeachScript PeachScript commented Jan 3, 2020

关联 issue

#45

新增 API

doc.locales

  • 类型:Array<string, string>
  • 默认值:[['en-US', 'EN'], ['zh-CN', '中文']]
  • 详细:

该配置为二维数组,第一项配置会作为站点默认的 locale;

每一项配置是一个长度为 2 的数组,数组的第一个值代表该 locale 的 name,会用于拼接路由前缀和检测文件名属于什么 locale,第二个值代表该 locale 的 label,会用作语言切换时的选项显示。

运行逻辑

如果目录树结构为:

.
└── src/
    ├── index.en-US.md
    ├── index.zh-CN.md

en-US 为默认语言的情况下,生成的路由配置会变成:

[
  {
    path: '/',
    // ...
  },
  {
    path: '/zh-CN',
    // ...
  }
]

menu 的内容也会随语言的切换而变化。

预览效果

multi-lang-preview

@PeachScript
Copy link
Member Author

已支持未翻译的路由 fallback 到默认语言

@PeachScript PeachScript merged commit 469190e into master Jan 11, 2020
@delete-merged-branch delete-merged-branch bot deleted the feature/multi-lang-support branch January 11, 2020 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant