Skip to content

Commit 80310b9

Browse files
committed
Update config
1 parent c08e8da commit 80310b9

File tree

3 files changed

+15
-37
lines changed

3 files changed

+15
-37
lines changed

book.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ translator = "rust-lang-cn, zzy"
77
additional-css = ["theme/reference.css"]
88
additional-js = ["language.js"]
99
git-repository-url = "https://github.com/rust-lang-cn/reference-cn"
10+
edit-url-template = "https://github.com/rust-lang-cn/reference-cn/edit/master/{path}"

language.js

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,58 +16,39 @@
1616
var link = "";
1717
var word = "";
1818
var home = "Home";
19-
20-
var edit_url = "https://github.com/rust-lang-cn"
21-
var github_id = document.getElementById("git-repository-button");
22-
if (github_id != null && github_id.parentNode.href != undefined) {
23-
edit_url = github_id.parentNode.href;
24-
var repo_name = edit_url.split('/').pop();
25-
var url_repo_name = repo_name.slice(0, -3);
26-
27-
if (url.indexOf(url_repo_name) > -1) {
28-
var html_file = url.split(url_repo_name).pop();
29-
} else if (url.indexOf(":3000") > -1) {
30-
var html_file = url.split(":3000").pop();
31-
} else {
32-
var html_file = '/';
33-
}
34-
35-
if (typeof default_homepage_md !== 'undefined') {
36-
edit_url += '/blob/master/src/' + default_homepage_md;
37-
} else if (html_file == '/') {
38-
edit_url += '/tree/master/src';
39-
} else {
40-
var md_len = html_file.indexOf('.html');
41-
if (md_len > -1) {
42-
var md_file = html_file.substring(0, md_len) + '.md';
43-
edit_url += '/blob/master/src' + md_file;
44-
}
45-
}
46-
}
47-
48-
var edit_node = '<a href="' + edit_url + '" title="报告错误或改进本页翻译" aria-label="报告错误或改进本页翻译" target="_blank"><i id="go-back-homepage" class="fa fa-pencil-square-o"></i></a>';
19+
var lang = "zh-CN";
20+
var changeLang = "切换到英语";
4921

5022
if (url.indexOf(search.en) != -1 && url.indexOf(search.en) === (url.indexOf(host) + host.length)) {
5123
link = url.replace(search.en, replaceWith.en);
5224
word = "简体中文";
53-
edit_node = "";
25+
lang = "en";
26+
changeLang = "Switch to Chinese"
5427
} else if (url.indexOf(search.zh_CN) != -1 && url.indexOf(search.zh_CN) === (url.indexOf(host) + host.length)) {
5528
link = url.replace(search.zh_CN, replaceWith.zh_CN);
5629
word = "English";
5730
home = "首页";
5831
}
5932

33+
var edit_id = document.getElementById("git-edit-button");
34+
if (edit_id != null && edit_id.parentNode != null) {
35+
edit_id.parentNode.target = "_blank";
36+
if (lang != "en") {
37+
edit_id.parentNode.title = "报告错误或改进本页翻";
38+
}
39+
}
40+
6041
var home_node = '';
6142
if (window.location.protocol == 'http:' || window.location.protocol == 'https:') {
6243
home_node = '<a href="' + home_url + '" title="' + home + '" aria-label="' + home + '"><i id="go-back-homepage" class="fa fa-home"></i></a>';
6344
}
6445
var lang_node = '';
6546
if (link != '') {
66-
lang_node = '<a href="' + link + '"><i id="change-language" class="fa fa-language"> ' + word + '</i></a>';
47+
lang_node = '<a href="' + link + '" title="' + changeLang + '" aria-label="' + changeLang + '"><i id="change-language-button" class="fa fa-language"> ' + word + '</i></a>';
6748
}
6849
var insertNode = document.getElementsByClassName('right-buttons');
6950
if (insertNode.length > 0) {
7051
var html = insertNode[0].innerHTML;
71-
insertNode[0].innerHTML = home_node + html + edit_node + lang_node;
52+
insertNode[0].innerHTML = home_node + html + lang_node;
7253
}
7354
})()

src/introduction.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,3 @@ We also want the reference to be as normative as possible, so if you see anythin
152152
[rustc book]: ../rustc/index.html
153153
[Notation]: notation.md
154154
[Zulip]: https://rust-lang.zulipchat.com/#narrow/stream/237824-t-lang.2Fdoc
155-
156-
<script>
157-
var default_homepage_md = "introduction.md";
158-
</script>

0 commit comments

Comments
 (0)