-
Notifications
You must be signed in to change notification settings - Fork 9
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
feature: i18n #343
Merged
feature: i18n #343
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Must
Optional
#342
对于同一篇博客,同时提供比如中英双语的两份 markdown 文件,默认展示默认的语言版本(比如 zh 中文)。进入中文页面后,如果当前文章存在其他语言的版本,则在页面顶部添加 i18n 国际化提示,让用户可以直接跳转到另一种语言(反之亦然)。
对于没有提供非默认语言的其他语言的文章,则页面保持现状,且 URL 不变。
文件名和 URL 实例参考 (设定中文为默认语言,其他语言不受任何限制,只需添加对应 markdown;
默认语言的中间后缀还得想方法去兼容当前现有的 URL,不然历史的 URL 会失效,除非手动写跳转逻辑):
article.md
orarticle.zh.md
example.com/blog/article
orexample.com/zh/blog/article
atom.xml
or/zh/atom.xml
article.en.md
example.com/en/blog/article
/en/atom.xml
article.ja.md
example.com/ja/blog/article
/ja/atom.xml
首页/索引页只展示默认语言的文章列表,如果该文章不存在默认语言版本则不在首页展示(否则会出现同一篇博客出现重复的情况),基于此,索引页也需要实现 i18n:
example.com
页面只展示默认语言文章,example.com/zh
同样可访问。example.com/en
只展示有 en 版本的文章。因此每一篇文章无论用几种语言撰写,都有必要提供一份默认语言的版本。
理论上,如果 locales 只有一种语言(默认),则网站所有 URL 和历史 URL 一致。