Skip to content

Commit 0b29c03

Browse files
committed
Add layout localization
1 parent 2e76300 commit 0b29c03

35 files changed

+394
-193
lines changed

_config.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@ theme: jekyll-theme-chirpy
77
# change below value to '/projectname'.
88
baseurl: ''
99

10-
# the HTML language tag › https://www.w3.org/International/questions/qa-choosing-language-tags
11-
lang: en-US
10+
# The language of the site layout › http://www.lingoes.net/en/translator/langcode.htm
11+
# Go to folder '_data/locales' to check the available language options
12+
lang: en
13+
14+
# The lang attribute of HTML › http://www.lingoes.net/en/translator/langcode.htm
15+
# We can specify a language different from the layout of the content.
16+
# If it is not assigned, the site will use the value of 'lang' instead.
17+
content_lang: ''
1218

1319
# Change to your timezone › http://www.timezoneconverter.com/cgi-bin/findzone/findzone
1420
timezone: Asia/Shanghai
1521

1622
# jekyll-seo-tag settings › https://github.com/jekyll/jekyll-seo-tag/blob/master/docs/usage.md
17-
# --------------------------
23+
# ↓ --------------------------
24+
1825
title: Chirpy # the main title
1926

2027
tagline: A text-focused Jekyll theme # it will display as the sub-title
@@ -47,7 +54,9 @@ social:
4754
# - https://www.linkedin.com/in/username
4855

4956
google_site_verification: google_meta_tag_verification # change to your verification string
50-
# --------------------------
57+
58+
# ↑ --------------------------
59+
5160

5261
google_analytics:
5362
id: '' # fill in your Google Analytics ID
@@ -164,3 +173,6 @@ jekyll-archives:
164173
permalinks:
165174
tag: /tags/:name/
166175
category: /categories/:name/
176+
177+
# Outdated configuration warning
178+
outdated: '-- Missing configuration options! --'

_data/date_format.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

_data/label.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

_data/locales/en.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# The layout text of site
2+
3+
# ----- Commons label -----
4+
5+
layout:
6+
post: Post
7+
category: Category
8+
tag: Tag
9+
10+
# The tabs of sidebar
11+
tabs:
12+
# format: <filename_without_extension>: <value>
13+
home: Home
14+
categories: Categories
15+
tags: Tags
16+
archives: Archives
17+
about: About
18+
19+
# text displayed in the search bar
20+
search:
21+
hint: search
22+
cancel: Cancel
23+
24+
panel:
25+
lastmod: Recent Update
26+
trending_tags: Trending Tags
27+
toc: Contents
28+
29+
# The liquid date format › http://strftime.net/
30+
date_format:
31+
tooltip: '%a, %b %e, %Y, %l:%M %p %z'
32+
post:
33+
long: '%b %e, %Y'
34+
short: '%b %e'
35+
archive_month: '%b'
36+
37+
copyright:
38+
# Shown at the bottom of the post
39+
license:
40+
template: This post is licensed under :LICENSE_NAME by the author.
41+
name: CC BY 4.0
42+
link: https://creativecommons.org/licenses/by/4.0/
43+
44+
# Displayed in the footer
45+
brief: Some rights reserved.
46+
verbose: >-
47+
Except where otherwise noted, the blog posts on this site are licensed
48+
under the Creative Commons Attribution 4.0 International (CC BY 4.0) License by the author.
49+
50+
meta: Powered by :PLATFORM with :THEME theme.
51+
52+
not_found:
53+
statment: Sorry, we've misplaced that URL or it's pointing to something that doesn't exist.
54+
hint_template: :HEAD_BAK to try finding it again, or search for it on the :ARCHIVES_PAGE.
55+
head_back: Head back Home
56+
archives_page: Archives page
57+
58+
# ----- Posts related labels -----
59+
60+
post:
61+
published: 'on'
62+
updated: Updated
63+
timeago:
64+
day: d ago
65+
hour: hr ago
66+
minute: min ago
67+
just_now: just now
68+
words: words
69+
pageview_measure: views
70+
read_time:
71+
unit: min
72+
prompt: read
73+
relate_posts: Further Reading
74+
share: Share
75+
button:
76+
next: Newer
77+
previous: Older
78+
copy:
79+
title: Copy link
80+
succeed: Link copied successfully!
81+
# pinned prompt of posts list on homepage
82+
pin_prompt: Pinned
83+
84+
# categories page
85+
categories:
86+
category_measure: categories
87+
post_measure: posts

_data/locales/zh-CN.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# The layout text of site
2+
3+
# ----- Commons label -----
4+
5+
layout:
6+
post: 文章
7+
category: 分类
8+
tag: 标签
9+
10+
# The tabs of sidebar
11+
tabs:
12+
# format: <filename_without_extension>: <value>
13+
home: 首页
14+
categories: 分类
15+
tags: 标签
16+
archives: 归档
17+
about: 关于
18+
19+
# text displayed in the search bar
20+
search:
21+
hint: 搜索
22+
cancel: 取消
23+
24+
panel:
25+
lastmod: 最近更新
26+
trending_tags: 热门标签
27+
toc: 目录
28+
29+
# The liquid date format › http://strftime.net/
30+
date_format:
31+
tooltip: '%a, %F, %R %z'
32+
post:
33+
long: '%F'
34+
short: '%m-%d'
35+
archive_month: '%m月'
36+
37+
copyright:
38+
# Shown at the bottom of the post
39+
license:
40+
template: 本文由作者按照 :LICENSE_NAME 进行授权
41+
name: CC BY 4.0
42+
link: https://creativecommons.org/licenses/by/4.0/
43+
44+
# Displayed in the footer
45+
brief: 保留部分权利。
46+
verbose: >-
47+
除非另有说明,本网站上的博客文章均由作者按照知识共享署名 4.0 国际 (CC BY 4.0) 许可协议进行授权。
48+
49+
meta: 本站由 :PLATFORM 生成,采用 :THEME 主题。
50+
51+
not_found:
52+
statment: 抱歉,我们放错了该 URL,或者它指向了不存在的内容。
53+
hint_template: :HEAD_BAK尝试再次查找它,或在:ARCHIVES_PAGE上搜索它。
54+
head_back: 返回主页
55+
archives_page: 归档页面
56+
57+
# ----- Posts related labels -----
58+
59+
post:
60+
published: 发表于
61+
updated: 更新于
62+
timeago:
63+
day: 天前
64+
hour: 小时前
65+
minute: 分钟前
66+
just_now: 刚刚
67+
words:
68+
pageview_measure: 次浏览
69+
read_time:
70+
unit: 分钟
71+
prompt: 阅读
72+
relate_posts: 相关文章
73+
share: 分享
74+
button:
75+
next: 下一篇
76+
previous: 上一篇
77+
copy:
78+
title: 分享链接
79+
succeed: 链接已复制!
80+
# pinned prompt of posts list on homepage
81+
pin_prompt: 顶置
82+
83+
# categories page
84+
categories:
85+
category_measure: 个分类
86+
post_measure: 篇文章

_data/rights.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

_includes/footer.html

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,30 @@
88
<p class="mb-0">
99
© {{ 'now' | date: "%Y" }}
1010
<a href="{{ site.social.links[0] }}">{{ site.social.name }}</a>.
11-
{% if site.data.rights.brief %}
11+
{% if site.data.locales[site.lang].copyright.brief %}
1212
<span data-toggle="tooltip" data-placement="top"
13-
title="{{ site.data.rights.verbose }}">{{ site.data.rights.brief }}</span>
13+
title="{{ site.data.locales[site.lang].copyright.verbose }}">{{ site.data.locales[site.lang].copyright.brief }}</span>
14+
{% else %}
15+
<span class="text-muted">{{ site.outdated }}</span>
1416
{% endif %}
1517
</p>
1618
</div>
1719

1820
<div class="footer-right">
1921
<p class="mb-0">
20-
Powered by
21-
<a href="https://jekyllrb.com" target="_blank" rel="noopener">Jekyll</a>
22-
with
23-
<a href="https://github.com/cotes2020/jekyll-theme-chirpy"
24-
target="_blank" rel="noopener">Chirpy</a>
25-
theme.
22+
{% capture _platform %}
23+
<a href="https://jekyllrb.com" target="_blank" rel="noopener">Jekyll</a>
24+
{% endcapture %}
25+
26+
{% capture _theme %}
27+
<a href="https://github.com/cotes2020/jekyll-theme-chirpy" target="_blank" rel="noopener">Chirpy</a>
28+
{% endcapture %}
29+
30+
{{ site.data.locales[site.lang].meta
31+
| default: 'Powered by :PLATFORM with :THEME theme.'
32+
| replace: ':PLATFORM', _platform | replace: ':THEME', _theme
33+
}}
34+
2635
</p>
2736
</div>
2837

_includes/head.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
{% if page.layout == 'home' or page.layout == 'post' %}
1010

11+
<!-- i18n for timeago.js -->
12+
<meta name="layout-lang" content="{{ site.lang | default: "en" }}">
13+
<meta name="day-prompt" content="{{ site.data.locales[site.lang].post.timeago.day | default: "d ago" }}">
14+
<meta name="hour-prompt" content="{{ site.data.locales[site.lang].post.timeago.hour | default: "hr ago" }}">
15+
<meta name="minute-prompt" content="{{ site.data.locales[site.lang].post.timeago.minute | default: "min ago" }}">
16+
<meta name="justnow-prompt" content="{{ site.data.locales[site.lang].post.timeago.just_now | default: "just now" }}">
17+
1118
{% if site.google_analytics.pv.proxy_endpoint %}
1219
<meta name="pv-proxy-endpoint" content="{{ site.google_analytics.pv.proxy_endpoint }}">
1320
{% endif %}

_includes/no-zero-date.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% comment %}
2+
Remove the zero padding from a month/day string
3+
{% endcomment %}
4+
5+
{% assign ret = include.date_str %}
6+
{% assign _first_chat = ret | slice: 0 %}
7+
8+
{% if _first_chat == '0' %}
9+
{% assign _last_idx = ret.size | minus: 1 %}
10+
{% assign ret = ret | slice: 1, _last_idx %}
11+
{% endif %}
12+
13+
{{ ret | replace: ' 0', ' ' }}

_includes/panel.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{% if update_list.size > 0 %}
1212

1313
<div id="access-lastmod" class="post">
14-
<span>{{- site.data.label.panel.lastmod | default: 'Recent Update' -}}</span>
14+
<span>{{- site.data.locales[site.lang].panel.lastmod | default: 'Recent Update' -}}</span>
1515
<ul class="post-content pl-0 pb-1 ml-1 mt-2">
1616

1717
{% for item in update_list %}
@@ -30,7 +30,7 @@
3030

3131
{% if trending_tags.size > 0 %}
3232
<div id="access-tags">
33-
<span>{{- site.data.label.panel.trending_tags | default: 'Trending Tags' -}}</span>
33+
<span>{{- site.data.locales[site.lang].panel.trending_tags | default: 'Trending Tags' -}}</span>
3434
<div class="d-flex flex-wrap mt-3 mb-1 mr-3">
3535

3636
{% for tag_name in trending_tags %}
@@ -48,7 +48,7 @@
4848
<script src="https://cdn.jsdelivr.net/gh/afeld/[email protected]/dist/bootstrap-toc.min.js"></script>
4949
<div id="toc-wrapper" class="pl-0 pr-4 mb-5">
5050
<span class="pl-3 pt-2 mb-2">
51-
{{- site.data.label.panel.toc | default: 'Contents' -}}
51+
{{- site.data.locales[site.lang].panel.toc | default: 'Contents' -}}
5252
</span>
5353
<nav id="toc" data-toggle="toc"></nav>
5454
</div>

0 commit comments

Comments
 (0)