Skip to content

Commit 57d7355

Browse files
authored
I18n (#111)
Add i18n base support. Relevant: #104 After this PR is merged, @mingcheng, you can proceed with the remaining tasks, building upon the foundation I've provided. Preview: https://zcb.code.xihale.top
1 parent 1a17c06 commit 57d7355

Some content is hidden

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

47 files changed

+219
-46
lines changed

README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 54 additions & 0 deletions

assets/style.css

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,8 @@ body {
7070
}
7171

7272
#prev-next {
73-
display: flex;
74-
justify-content: space-between;
75-
flex-wrap: wrap;
76-
align-items: center;
77-
margin-top: 20px;
78-
padding-top: 5px;
79-
border-top: 2px solid var(--border);
80-
}
81-
82-
#prev-next a {
83-
text-decoration: none;
84-
}
85-
#prev-next > :last-child {
86-
margin-left: auto;
87-
text-align: right;
88-
}
89-
#prev-next > :first-child span::before {
90-
content: "←";
91-
}
92-
93-
#prev-next > :last-child span::after {
94-
content: "→";
73+
padding: 15px 0;
74+
border-bottom: 1px solid var(--border);
9575
}
9676

9777
a {
@@ -165,6 +145,20 @@ html {
165145
max-width: 50rem;
166146
}
167147

148+
article {
149+
border-bottom: 1px solid var(--border);
150+
}
151+
152+
#footer {
153+
margin: 15px 0;
154+
text-align: center;
155+
font-size: 0.85rem;
156+
}
157+
158+
#footer .langs * {
159+
margin: 0 5px;
160+
}
161+
168162
.toc {
169163
width: var(--toc-width);
170164
min-width: var(--toc-width);
@@ -176,12 +170,11 @@ html {
176170
/* word-break: normal; */
177171
}
178172
.toc a {
179-
text-decoration: none;
180173
line-break: auto;
181174
}
182175

183176
.toc a:hover {
184-
text-decoration: underline;
177+
color: #5eafcd;
185178
}
186179

187180
.toc a[aria-current="page"] {
@@ -291,4 +284,9 @@ html {
291284

292285
h1{
293286
margin-bottom: 0;
287+
}
288+
#content-header{
289+
margin-bottom: 10px;
290+
padding-bottom: 10px;
291+
border-bottom: 1px solid var(--border)
294292
}

i18n/en-US.ziggy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"site_title": "Zig Cookbook",
3+
"introduction": "Introduction",
4+
"contributing": "Contributing",
5+
"license": "License",
6+
"toggle_toc": "Toggle Table of Contents",
7+
"prev": "Previous: ",
8+
"next": "Next: ",
9+
"languages_menu": "This page is available in the following languages",
10+
"footer_copyright": "License: text: CC BY-SA 4.0; code: MIT",
11+
}

i18n/zh-CN.ziggy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"site_title": "Zig Cookbook",
3+
"introduction": "介绍",
4+
"contributing": "贡献",
5+
"license": "许可证",
6+
"toggle_toc": "切换目录",
7+
"prev": "上一示例:",
8+
"next": "下一示例:",
9+
"languages_menu": "此页面提供以下语言的版本",
10+
"footer_copyright": "许可证: 文字:CC BY-NC-SA 4.0;代码:MIT",
11+
}

layouts/section.shtml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,39 @@
44
</head>
55
<body id="body">
66
<div class="mobile-header">
7-
<button id="toc-toggle" aria-expanded="false" aria-controls="toc" aria-label="Toggle table of contents">☰</button>
8-
<a class="brand" href="/" :text="$site.title"></a>
7+
<button id="toc-toggle" aria-expanded="false" aria-controls="toc" aria-label="$i18n.get('toggle_toc')">☰</button>
8+
<a class="brand" href="/" :text="$i18n.get('site_title')"></a>
99
</div>
1010
<div class="toc" id="toc">
1111
<ctx :html="$site.page('toc').content()"></ctx>
1212
</div>
1313
<div class="body">
1414
<div class="content">
1515
<article>
16-
<h1 :text="$page.title"></h1>
16+
<div id="content-header">
17+
<h1 :text="$page.title"></h1>
18+
</div>
1719
<div :html="$page.content()"></div>
1820
</article>
19-
<div id="prev-next" :if="$page.isSection().not()">
20-
<div :if="$page.prevPage?()">
21-
<a href="$if.link()">
22-
<span :text="$if.title"></span>
23-
</a>
21+
<ctx :if="$page.isSection().not()">
22+
<div id="prev-next">
23+
<div :if="$page.prevPage?()">
24+
<span :text="$i18n.get('prev')"></span><a href="$if.link()" :text="$if.title"></a>
25+
</div>
26+
<div :if="$page.nextPage?()">
27+
<span :text="$i18n.get('next')"></span><a href="$if.link()" :text="$if.title"></a>
28+
</div>
2429
</div>
25-
<div :if="$page.nextPage?()">
26-
<a href="$if.link()">
27-
<span :text="$if.title"></span>
30+
</ctx>
31+
<div id="footer">
32+
<div>&copy; 2025. All rights reserved.</div>
33+
<div :text="$i18n.get('languages_menu')"></div>
34+
<div class="langs" :loop="$page.locales()">
35+
<a href="$loop.it.link()">
36+
<ctx :text="$loop.it.site().localeName()"></ctx><ctx :if="$loop.it.site().localeName().eql('English')">(Original)</ctx>
2837
</a>
2938
</div>
3039
</div>
3140
</div>
3241
</div>
33-
</body>
42+
</body>

layouts/templates/base.shtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head id="head">
44
<meta charset="utf-8">
55
<meta name="viewport" content="initial-scale=1">
6-
<title :text="$site.title"></title>
6+
<title :text="$i18n.get('site_title')"></title>
77
<link type="text/css" rel="stylesheet" href="$site.asset('style.css').link()">
88
<link type="text/css" rel="stylesheet" href="$site.asset('highlight.css').link()">
99
<super>
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)