Skip to content

Commit 79f8a66

Browse files
committed
website: make the About section properly bilingual
The About pages (Donate/Copyright/Acknowledgements) always rendered with Chinese chrome regardless of the reader's language, and Acknowledgements stacked English on top of Chinese. An English reader reached them from the English menu and got a Chinese page. Introduce an 'about-en' page type (the theme's 'type' field selects both menu language and which section's table-of-contents to list, so a separate type is the clean way to split). Route the shared partials -- header, page, sidebar, layout -- through a single isEn = book-en-us || about-en helper. Add English About pages under /about/en/, point the English menu and the English book footer at them, and reduce each Chinese About page to Chinese only. donate.md becomes a committed source file (was generated from assets/, which stays bilingual for the GitHub README), so it drops out of the Makefile copy/clean and .gitignore.
1 parent 845f01f commit 79f8a66

11 files changed

Lines changed: 72 additions & 24 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ website/src/modern-cpp/zh-cn/*
4040
website/src/modern-cpp/en-us/*
4141
website/src/modern-cpp/exercises
4242
website/src/modern-cpp/code
43-
website/src/modern-cpp/about/donate.md
4443
website/src/modern-cpp/assets/alipay.jpg
4544
website/src/modern-cpp/assets/cover-2nd-en.png
4645
website/src/modern-cpp/assets/cover-2nd.png

website/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ all: clean
77
cp ../assets/cover-2nd-en-logo.png ./src/modern-cpp/assets/cover-2nd-en-logo.png
88
cp ../assets/alipay.jpg ./src/modern-cpp/assets/alipay.jpg
99
cp ../assets/wechat.jpg ./src/modern-cpp/assets/wechat.jpg
10-
cp ../assets/donate.md ./src/modern-cpp/about/
1110
cp -r ../assets/figures ./src/modern-cpp/assets/figures
1211
cp -r ../exercises ./src/modern-cpp/
1312
cp -r ../code ./src/modern-cpp/
@@ -23,7 +22,6 @@ clean:
2322
./src/modern-cpp/assets/figures \
2423
./src/modern-cpp/assets/alipay.jpg \
2524
./src/modern-cpp/assets/wechat.jpg \
26-
./src/modern-cpp/about/donate.md \
2725
./src/modern-cpp/code \
2826
./src/modern-cpp/exercises \
2927
public db.json src/modern-cpp/zh-cn src/modern-cpp/en-us

website/src/modern-cpp/about/ack.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ type: about
44
order: 4
55
---
66

7-
## Acknowledgements
8-
9-
This book was originally written in Chinese by [Changkun Ou](https://changkun.de).
10-
11-
The author has limited time and language skills. If readers find any mistakes in the book or any language improvements, please feel free to open an [Issue](https://github.com/changkun/modern-cpp-tutorial/issues) or start a [Pull request](https://github.com/changkun/modern-cpp-tutorial/pulls). For detailed guidelines and checklist, please refer to [How to contribute](CONTRIBUTING.md).
12-
13-
The author is grateful to all contributors, including but not limited to [Contributors](https://github.com/changkun/modern-cpp-tutorial/graphs/contributors).
14-
157
## 致谢
168

17-
笔者时间和水平有限,如果读者发现书中内容的错误,欢迎提 [Issue](https://github.com/changkun/modern-cpp-tutorial/issues),或者直接提 [Pull request](https://github.com/changkun/modern-cpp-tutorial/pulls)。详细贡献指南请参考[如何参与贡献](CONTRIBUTING.md),由衷感谢每一位指出本书中出现错误的读者,包括但不限于 [Contributors](https://github.com/changkun/modern-cpp-tutorial/graphs/contributors)
9+
笔者时间和水平有限,如果读者发现书中内容的错误,欢迎提 [Issue](https://github.com/changkun/modern-cpp-tutorial/issues),或者直接提 [Pull request](https://github.com/changkun/modern-cpp-tutorial/pulls)。详细贡献指南请参考[如何参与贡献](https://github.com/changkun/modern-cpp-tutorial/blob/master/CONTRIBUTING.md),由衷感谢每一位指出本书中出现错误的读者,包括但不限于 [Contributors](https://github.com/changkun/modern-cpp-tutorial/graphs/contributors)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: 资助
3+
type: about
4+
order: 1
5+
---
6+
7+
## 资助
8+
9+
如果你认为本书对你起到了帮助,并希望赞助作者,可以通过下面的二维码给予支持:
10+
11+
|微信|支付宝|
12+
|:--:|:--:|
13+
|![](../assets/wechat.jpg) | ![](../assets/alipay.jpg)|
14+
15+
你也可以通过 PayPal 资助:
16+
17+
[![](https://img.shields.io/badge/donate-PayPal-104098.svg?style=popout-square&logo=PayPal)](https://www.paypal.me/changkunde/4.99eur)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Acknowledgements
3+
type: about-en
4+
order: 4
5+
---
6+
7+
## Acknowledgements
8+
9+
This book was originally written in Chinese by [Changkun Ou](https://changkun.de).
10+
11+
The author has limited time and language skills. If readers find any mistakes in the book or any language improvements, please feel free to open an [Issue](https://github.com/changkun/modern-cpp-tutorial/issues) or start a [Pull request](https://github.com/changkun/modern-cpp-tutorial/pulls). For detailed guidelines and checklist, please refer to [How to contribute](https://github.com/changkun/modern-cpp-tutorial/blob/master/CONTRIBUTING.md).
12+
13+
The author is grateful to all contributors, including but not limited to [Contributors](https://github.com/changkun/modern-cpp-tutorial/graphs/contributors).
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Copyright
3+
type: about-en
4+
order: 3
5+
---
6+
7+
<a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/80x15.png" /></a>
8+
9+
This book is written by [Changkun Ou](https://github.com/changkun) and licensed under the [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License](https://creativecommons.org/licenses/by-nc-nd/4.0/). The code in this project is open sourced under the [MIT](https://opensource.org/licenses/MIT) license.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Donate
3+
type: about-en
4+
order: 1
5+
---
6+
7+
## Donate
8+
9+
I would love it if you support me to make the book better:
10+
11+
[![](https://img.shields.io/badge/donate-PayPal-104098.svg?style=popout-square&logo=PayPal)](https://www.paypal.me/changkunde/4.99eur)
12+
13+
If you are in mainland China, you can also support via WeChat or AliPay:
14+
15+
|WeChat|AliPay|
16+
|:--:|:--:|
17+
|![](../../assets/wechat.jpg) | ![](../../assets/alipay.jpg)|

website/themes/moderncpp/layout/page.ejs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
<% var isEn = page.type == 'book-en-us' || page.type == 'about-en' %>
12
<% if (page.type) { %>
23
<%- partial('partials/sidebar', { type: page.type, index: page.index }) %>
34
<% } else { %>
45
<div class="sidebar">
56
<ul class="main-menu">
6-
<% if (page.type == 'book-en-us') { %>
7+
<% if (isEn) { %>
78
<%- partial('partials/main_menu_en', { context: 'nav' }) %>
89
<% } else {%>
910
<%- partial('partials/main_menu', { context: 'nav' }) %>
@@ -22,14 +23,14 @@
2223
<% }) %>
2324
</div>
2425

25-
<% if (page.type == 'book-en-us') { %>
26+
<% if (isEn) { %>
2627
<div class="footer">
2728
<p>
2829
<a href="https://changkun.de">Changkun Ou</a> &copy; 2016-<%- new Date().getFullYear() %>.
2930
The book is licensed under <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0</a>, code is open sourced under the <a href="https://opensource.org/licenses/MIT" target="_blank">MIT</a> License. </a>
3031
</p>
3132
<p>
32-
If you like the book, you could <a href="/modern-cpp/about/donate.html">donate the author</a>.
33+
If you like the book, you could <a href="/modern-cpp/about/en/donate.html">donate the author</a>.
3334
</p>
3435
</div>
3536
<% } else {%>

website/themes/moderncpp/layout/partials/header.ejs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
<% var isEn = page.type == 'book-en-us' || page.type == 'about-en' %>
12
<div id="header">
23
<a id="logo" href="<%- url_for("/modern-cpp/") %>">
3-
<% if (page.type == 'book-en-us') { %>
4+
<% if (isEn) { %>
45
<img src="<%- url_for("/modern-cpp/assets/cover-2nd-en-logo.png") %>">
56
<span>Modern C++ Tutorial: C++11 to C++26 On the Fly</span>
67
<% } else {%>
@@ -9,7 +10,7 @@
910
<% } %>
1011
</a>
1112
<ul id="nav">
12-
<% if (page.type == 'book-en-us') { %>
13+
<% if (isEn) { %>
1314
<%- partial('partials/main_menu_en', { context: 'nav' }) %>
1415
<% } else {%>
1516
<%- partial('partials/main_menu', { context: 'nav' }) %>

website/themes/moderncpp/layout/partials/main_menu_en.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<a class="nav-link">About</a><span class="arrow"></span>
1616
<ul class="nav-dropdown">
1717
<li><ul>
18-
<li><a class="nav-link" href="<%- url_for("/modern-cpp/about/donate.html") %>" >Donate</a></li>
19-
<li><a class="nav-link" href="<%- url_for("/modern-cpp/about/copyright.html") %>" >Copyright</a></li>
20-
<li><a class="nav-link" href="<%- url_for("/modern-cpp/about/ack.html") %>" >Acknowledgements</a></li>
18+
<li><a class="nav-link" href="<%- url_for("/modern-cpp/about/en/donate.html") %>" >Donate</a></li>
19+
<li><a class="nav-link" href="<%- url_for("/modern-cpp/about/en/copyright.html") %>" >Copyright</a></li>
20+
<li><a class="nav-link" href="<%- url_for("/modern-cpp/about/en/ack.html") %>" >Acknowledgements</a></li>
2121
</ul></li>
2222
</ul>
2323
</li>

0 commit comments

Comments
 (0)