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.
尝试通过插件支持多语言
插件会根据内容所在文件的名称判断文件对应的语言区域代码,具体流程如下:
首先需要在
_config.yml中配置字符串数组类型参数locales例如locales: [zh, zh-TW, en]作为系统支持的语言区域代码集合,插件获取locale作为系统的默认语言区域代码故默认代码的可以不写。然后插件会在
:site的:pre_render时期遍历系统内的所有页面Page与文档Document根据其实际对应的文件名判断当前文档的语言区域代码。以配置locale: zhlocales: [zh, zh-TW, en]为例index.mdindex.es.md的文件名中均未包含配置列表中的代码因此会统一采用默认代码zh而help.en.md与faq.zh-TW.md会分别被识别为en与zh-TW。多语言内容的
permalink规则为/{lang}{default content permalink}例如/test/a.md对应的permalink为/test-a.html则/test/a.en.md对应的permalink为/en/test-a.html。因此要求内容必须存在默认语言版本,如无默认语言版本则多语言插件则不会处理改内容。需要启用多语言的内容需要在页面 data 中配置
i18n: true。插件为启用了多语言的内容启用了回退页面,即如何某种语言的内容并不存在,插件会自动在系统中使用语言代码匹配回退页面(当前是使用默认语言作为回退页面,即页面页面不存在时使用默认语言的内容填充,并使用警告提示用户当前显示语言并非实际页面对应的语言)。
关联 ISSUES