Skip to content

Commit 15af70e

Browse files
authored
支持多语言
1 parent b317537 commit 15af70e

File tree

117 files changed

+2108
-1885
lines changed

Some content is hidden

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

117 files changed

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

_build/config.zh-TW.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cache_dir: .jekyll-cache/zh-TW
2+
include:
3+
- _pages
4+
- "*.zh-TW.md"
5+
- "*.zh-TW.json"
6+
exclude:
7+
- assets/
8+
- scripts/
9+
- LICENSE
10+
- "*.md"
11+
- "*.json"
12+
locale: zh-TW
13+
title: HMCL 文檔
14+
head_scripts:
15+
- /assets/js/theme.zh-TW.js
16+
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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
shopt -s globstar
2+
3+
exclude_target=("./_build" "./_data", "_data_bak" "./_site" "./_site_temp" "./_includes" "./_layouts")
4+
5+
echo "cp -r _data _data_bak"
6+
cp -r _data _data_bak
7+
8+
bundle exec jekyll build --trace --verbose --destination _site --config _config.yml,"$1"
9+
10+
for config in ./_build/config.*.yml; do
11+
[ -f "$config" ] || continue
12+
13+
language="${config#./_build/config.}"
14+
language="${language%.yml}"
15+
echo "build $language version"
16+
17+
echo "rm -rf _data && cp -r _data_bak _data"
18+
rm -rf _data && cp -r _data_bak _data
19+
for data in ./_data/**/*."$language".*; do
20+
[ -f "$data" ] || continue
21+
dest="${data/.$language./.}"
22+
echo "mv $data $dest"
23+
mv "$data" "$dest"
24+
done
25+
26+
for target in ./_*; do
27+
[ -f "$target" ] && continue
28+
[[ " ${exclude_target[*]} " == *" $target "* ]] && continue
29+
30+
find $target -type f -name "*.*" ! -name "*.*.*" | while read -r file; do
31+
dir="${file%/*}"
32+
ext="${file##*.}"
33+
base="${file##*/}"
34+
name="${base%%.*}"
35+
language_file="$dir/$name.$language.$ext"
36+
[ -f $language_file ] && continue
37+
echo "cp $file $dir/$name.$language.$ext"
38+
cp "$file" "$dir/$name.$language.$ext"
39+
done
40+
done
41+
42+
bundle exec jekyll build --trace --verbose --destination _site_temp --config "_config.yml,_build/config.$language.yml,$1"
43+
44+
rm -rf ./_site_temp/assets
45+
rm -rf ./_site_temp/feed.xml
46+
rm -rf ./_site_temp/robots.txt
47+
rm -rf ./_site_temp/sitemap.xml
48+
cp -r ./_site_temp/* ./_site/
49+
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)