You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
website: show one language at a time on the homepage
Replace the stacked Chinese+English heroes on the root page with a
single hero plus a 中文/English toggle. The language is auto-detected
from the browser on first visit and remembered in localStorage; the
non-active language is hidden by default to avoid a flash of both.
The book is licensed under <arel="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 <ahref="https://opensource.org/licenses/MIT"target="_blank">MIT</a> License. </a>
59
68
</p>
60
69
</div>
70
+
71
+
<script>
72
+
(function () {
73
+
var sections =document.querySelectorAll('.lang');
74
+
var buttons =document.querySelectorAll('.lang-btn');
75
+
functionapply(lang) {
76
+
for (var i =0; i <sections.length; i++) {
77
+
sections[i].style.display= sections[i].getAttribute('data-lang') === lang ?'':'none';
78
+
}
79
+
for (var j =0; j <buttons.length; j++) {
80
+
var on = buttons[j].getAttribute('data-set') === lang;
81
+
buttons[j].className= on ?'lang-btn active':'lang-btn';
82
+
}
83
+
document.documentElement.lang= lang ==='zh'?'zh-CN':'en';
0 commit comments