Skip to content

Commit 2fab0f0

Browse files
authored
支持多语言
1 parent b317537 commit 2fab0f0

File tree

98 files changed

+830
-1851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+830
-1851
lines changed

.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ steps:
1414
commands:
1515
- bundle config mirror.https://rubygems.org https://mirrors.cloud.tencent.com/rubygems
1616
- bundle install --verbose
17-
- bundle exec jekyll build --trace --verbose
17+
- bash _build/setup.sh
1818
volumes:
1919
- name: dist
2020
path: /drone/src/_site

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ assets
3232
* ...
3333
```
3434

35-
其中,`<category>` 表示分类,如 `multiplayer` 表示多人游戏、`modpack` 表示整合包,`<article>` 表示你的文章的英文名(尖括号表示占位符,请替换为文章名称,不要直接提交 '`<article>`'),请仅使用英文字母、数字、中划线、下划线字符,不要使用空格、中文字符。请确保 md 文件名和文件夹名一致。具体可以参考已有文章目录格式。
35+
其中,`<category>` 表示分类,如 `modpack` 表示整合包,`<article>` 表示你的文章的英文名(尖括号表示占位符,请替换为文章名称,不要直接提交 '`<article>`'),请仅使用英文字母、数字、中划线、下划线字符,不要使用空格、中文字符。请确保 md 文件名和文件夹名一致。具体可以参考已有文章目录格式。
3636

3737
每篇文章由 Markdown 编写的 `<article>.md` 文件及附带图片组成。文章的图片请放置到 `/assets/img/docs/<article>` 目录中。
3838

@@ -42,10 +42,5 @@ assets
4242

4343
切记不要在一个添加新文章的 PR 里修改其他文章的内容。
4444

45-
### 修改已有文章
46-
47-
修改已有文章时,请确保你的 PR 仅修改一个文章内容,并在该文章里署名。
48-
49-
### 更新索引
5045

5146
在添加或修改文章后,请更新索引文件 `index.json`,以便 HMCL 展示你新添加的文件。

_build/config.en.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cache_dir: .jekyll-cache/en
2+
include:
3+
- _pages
4+
- "*.en.md"
5+
exclude:
6+
- assets/
7+
- scripts/
8+
- LICENSE
9+
- "*.md"
10+
locale: en
11+
title: HMCL Document
12+
head_scripts:
13+
- /assets/js/theme.en.js
14+
build: true

_build/config.zh-TW.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cache_dir: .jekyll-cache/zh-TW
2+
include:
3+
- _pages
4+
- "*.zh-TW.md"
5+
exclude:
6+
- assets/
7+
- scripts/
8+
- LICENSE
9+
- "*.md"
10+
locale: zh-TW
11+
title: HMCL 文檔
12+
head_scripts:
13+
- /assets/js/theme.zh-TW.js
14+
build: true

_build/config.zh.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cache_dir: .jekyll-cache/zh
2+
exclude:
3+
- assets/
4+
- scripts/
5+
- README.md
6+
- LICENSE
7+
- "*.*.*"
8+
locale: zh
9+
build: true

_build/setup.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
shopt -s globstar
2+
3+
exclude_target=("./_build" "./_data", "_data_bak" "./_site" "./_site_temp" "./_includes" "./_layouts")
4+
5+
exclude_build_file=("./_site_temp/sitemap.xml", "./_site_temp/robots.txt")
6+
exclude_build_folder=("./_site_temp/assets")
7+
8+
echo "cp -r _data _data_bak"
9+
cp -r _data _data_bak
10+
11+
bundle exec jekyll build --trace --verbose --destination _site --config _config.yml,"$1"
12+
13+
for config in ./_build/config.*.yml; do
14+
[ -f "$config" ] || continue
15+
16+
language="${config#./_build/config.}"
17+
language="${language%.yml}"
18+
echo "build $language version"
19+
20+
echo "rm -rf _data && cp -r _data_bak _data"
21+
rm -rf _data && cp -r _data_bak _data
22+
for data in ./_data/**/*."$language".*; do
23+
[ -f "$data" ] || continue
24+
dest="${data/.$language./.}"
25+
echo "mv $data $dest"
26+
mv "$data" "$dest"
27+
done
28+
29+
for target in ./_*; do
30+
[ -f "$target" ] && continue
31+
[[ " ${exclude_target[*]} " == *" $target "* ]] && continue
32+
33+
find $target -type f -name "*.*" ! -name "*.*.*" | while read -r file; do
34+
dir="${file%/*}"
35+
ext="${file##*.}"
36+
base="${file##*/}"
37+
name="${base%%.*}"
38+
language_file="$dir/$name.$language.$ext"
39+
[ -f $language_file ] && continue
40+
echo "cp $file $dir/$name.$language.$ext"
41+
cp "$file" "$dir/$name.$language.$ext"
42+
done
43+
done
44+
45+
bundle exec jekyll build --trace --verbose --destination _site_temp --config "_config.yml,_build/config.$language.yml,$1"
46+
47+
for build_src in ./_site_temp/**/*; do
48+
[ -f "$build_src" ] || continue
49+
[[ " ${exclude_build_file[@]} " =~ " $build_src " ]] && continue
50+
for dir in "${exclude_build_folder[@]}"; do
51+
[[ "$build_src" == "$dir"* ]] && continue 2
52+
done
53+
54+
build_dst="./_site/${build_src#./_site_temp/}"
55+
echo "cp $build_src $build_dst"
56+
cp "$build_src" "$build_dst"
57+
done
58+
done

_changelog/dev.en.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Dev Change Log
3+
channel: dev
4+
---

_changelog/dev.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
---
22
title: 开发版更新日志
33
date: 2021-08-22 23:18:02 +0800
4-
categories: 更新日志
5-
note: Changelogs are written in Chinese.
6-
hits: true
7-
toc: true
4+
channel: dev
85
---
9-
10-
{% assign changelogs = site.changelogs | where_exp: "item", "item.relative_path contains 'dev/'" | reverse %}
11-
{% for item in changelogs %}
12-
{% assign path = item.relative_path | split: '.' | first | split: '/' %}
13-
{% assign end = path | size %}
14-
{% assign version = path | slice: 2, end | join: '.' %}
15-
<h1 id="{% if forloop.index == 1 %}nowchange{% else %}HMCL-{{ version }}{% endif %}">HMCL {{ version }}</h1>
16-
<div>{{ item.content | markdownify }}</div>
17-
{% endfor %}

_changelog/dev.zh-TW.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: 開髮版更新日誌
3+
channel: dev
4+
---

_changelog/stable.en.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
title: Stable Change Log
3+
---

0 commit comments

Comments
 (0)