Skip to content

Commit fe58e10

Browse files
committed
Add multilingual support for titles and navigation in templates #53
1 parent 38b5eab commit fe58e10

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

layout/includes/head.ejs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<%
2+
var lang = config.language || 'zh-CN';
23
var title = page.title;
34
// tags, categories, about pages title
45
if (title === 'tags') {
5-
title = '标签 | '+ config.title;
6+
title = lang === 'en' ? 'Tags | ' + config.title : '标签 | ' + config.title;
67
} else if (title === 'categories') {
7-
title = '分类归档 | '+ config.title;
8+
title = lang === 'en' ? 'Categories | ' + config.title : '分类归档 | ' + config.title;
89
} else if (title === 'about') {
9-
title = '关于 | '+ config.title;
10+
title = lang === 'en' ? 'About | ' + config.title : '关于 | ' + config.title;
1011
} else if (!title) {
1112
title = config.title;
1213
}

layout/includes/post-list.ejs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@
3838

3939
<% if (page.total > 1) { %>
4040
<div class="pagination-container">
41+
<% var lang = config.language || 'zh-CN'; %>
4142
<% if (page.prev) { %>
42-
<a href="<%- url_for(page.prev_link) %>" class="prev"><i class="icon icon-arrow-ios-back-outline"></i> 上一页</a>
43+
<a href="<%- url_for(page.prev_link) %>" class="prev"><i class="icon icon-arrow-ios-back-outline"></i> <%= lang === 'en' ? 'Prev' : '上一页' %></a>
4344
<% } %>
4445
<% if (page.next) { %>
45-
<a href="<%- url_for(page.next_link) %>" class="next">下一页 <i class="icon icon-arrow-ios-forward-outline"></i></a>
46+
<a href="<%- url_for(page.next_link) %>" class="next"><%= lang === 'en' ? 'Next' : '下一页' %> <i class="icon icon-arrow-ios-forward-outline"></i></a>
4647
<% } %>
4748
</div>
4849
<% } %>

layout/post.ejs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
<div class="next-post">
4040
<a class="purple-link" href="<%- url_for(page.next.path) %>">
4141
<h3 class="post-title">
42-
下一篇:<%= page.next.title %>
42+
<% var lang = config.language || 'zh-CN'; %>
43+
<%= lang === 'en' ? 'Next post: ' : '下一篇:' %><%= page.next.title %>
4344
</h3>
4445
</a>
4546
</div>

layout/tags.ejs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
<div class="content-container">
44

55
<div class="tags-container">
6+
<% var lang = config.language || 'zh-CN'; %>
67
<% if (site.tags.length <= 0) { %>
7-
<a class="tag" href="">暂无标签</a>
8+
<a class="tag" href=""><%= lang === 'en' ? 'No tags yet' : '暂无标签' %></a>
89
<% } %>
910
<% site.tags.forEach((tag) => { %>
1011
<a class="tag" href="<%= url_for(tag.path) %>"><%= tag.name %></a>

0 commit comments

Comments
 (0)