Skip to content

Commit 2b30171

Browse files
committed
english translation of readme
1 parent ed716f0 commit 2b30171

35 files changed

+5018
-4886
lines changed

.vscode/launch.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
// 使用 IntelliSense 了解相关属性。
3-
// 悬停以查看现有属性的描述。
4-
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
2+
// Use IntelliSense for related attributes.
3+
// Hover to see descriptions of existing properties.
4+
// For more information, please visit:https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
77
{

README.md

Lines changed: 2847 additions & 2716 deletions
Large diffs are not rendered by default.

ctl/README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
# LeetCode-Go ctl
22

3-
## 配置方法
3+
## Configuration Method
44

5-
1.`.gitignore`中,添加一行`*.toml`
6-
2.`LeetCode-Go`目录下,添加文本文件`config.toml`
7-
3. 把以下内容复制到`config.toml`中。
8-
4.`config.toml`中的`test`分别修改为你的 leetcode `用户名``密码`
9-
5. 去 leetcode 登录后,把网站 cookie 复制 (需要复制 csrftoken 和 LEETCODE_SESSION) 并替换 `config.toml`中的`Cookie`
5+
1. In `.gitignore`, add a line `*.toml`
6+
2. In the `LeetCode-Go` directory, add a text file `config.toml`.
7+
3. Copy the following content into `config.toml`.
8+
4. Change `test` in `config.toml` to your leetcode `username` and `password` respectively.
9+
5. After logging in to leetcode, copy the website cookie (need to copy csrftoken and LEETCODE_SESSION) and
10+
replace `Cookie` in `config.toml`.
1011

1112
```toml
12-
Username="test"
13-
Password="test"
14-
Cookie="csrftoken=XXXXXXXXX; LEETCODE_SESSION=YYYYYYYY;"
15-
CSRFtoken="ZZZZZZZZ"
13+
Username = "test"
14+
Password = "test"
15+
Cookie = "csrftoken=XXXXXXXXX; LEETCODE_SESSION=YYYYYYYY;"
16+
CSRFtoken = "ZZZZZZZZ"
1617
```
1718

18-
## PDF 生成
19+
## PDF generation
1920

20-
`leetcode-go pdf` 命令先生成书籍内容的合并版本 pdf.md,再用 vscode 或者其他支持 toc 目录生成的工具,生成 toc。最后用 Typora 把 md 文件转换成 pdf。就可以发布 release 新版本了。
21+
Use the `leetcode-go pdf` command to generate the merged version pdf.md of the book content, and then use vscode or
22+
other tools that support toc directory generation to generate toc. last use
23+
Typora converts md files to pdf. You can release a new version.

ctl/label.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
var (
1818
chapterOneFileOrder = []string{"_index", "Data_Structure", "Algorithm", "Time_Complexity"}
19-
chapterOneMenuOrder = []string{"_index", "#关于作者", "Data_Structure", "Algorithm", "Time_Complexity"}
19+
chapterOneMenuOrder = []string{"_index", "#about the author", "Data_Structure", "Algorithm", "Time_Complexity"}
2020
chapterTwoFileOrder = []string{"_index", "Array", "String", "Two_Pointers", "Linked_List", "Stack", "Tree", "Dynamic_Programming", "Backtracking", "Depth_First_Search", "Breadth_First_Search",
2121
"Binary_Search", "Math", "Hash_Table", "Sorting", "Bit_Manipulation", "Union_Find", "Sliding_Window", "Segment_Tree", "Binary_Indexed_Tree"}
2222
chapterThreeFileOrder = []string{"_index", "Segment_Tree", "UnionFind", "LRUCache", "LFUCache"}
@@ -35,13 +35,13 @@ var (
3535

3636
chapterMap = map[string]map[string]string{
3737
"ChapterOne": {
38-
"_index": "第一章 序章",
39-
"Data_Structure": "1.1 数据结构知识",
40-
"Algorithm": "1.2 算法知识",
41-
"Time_Complexity": "1.3 时间复杂度",
38+
"_index": "Chapter 1 Prologue",
39+
"Data_Structure": "1.1 Data structure knowledge",
40+
"Algorithm": "1.2 Algorithm knowledge",
41+
"Time_Complexity": "1.3 Time Complexity",
4242
},
4343
"ChapterTwo": {
44-
"_index": "第二章 算法专题",
44+
"_index": "Chapter 2 Algorithms Topics",
4545
"Array": "2.01 Array",
4646
"String": "2.02 String",
4747
"Two_Pointers": "2.03 ✅ Two Pointers",
@@ -63,14 +63,14 @@ var (
6363
"Binary_Indexed_Tree": "2.19 ✅ Binary Indexed Tree",
6464
},
6565
"ChapterThree": {
66-
"_index": "第三章 一些模板",
66+
"_index": "Chapter 3 Some Templates",
6767
"Segment_Tree": "3.1 Segment Tree",
6868
"UnionFind": "3.2 UnionFind",
6969
"LRUCache": "3.3 LRUCache",
7070
"LFUCache": "3.4 LFUCache",
7171
},
7272
"ChapterFour": {
73-
"_index": "第四章 Leetcode 题解",
73+
"_index": "Chapter 4 Leetcode Solution",
7474
},
7575
}
7676
)
@@ -79,7 +79,7 @@ func getChapterFourFileOrder() ([]string, []int) {
7979
solutions, solutionIds := util.LoadChapterFourDir()
8080
chapterFourFileOrder := []string{"_index"}
8181
chapterFourFileOrder = append(chapterFourFileOrder, solutions...)
82-
fmt.Printf("ChapterFour 中包括 _index 有 %v 个文件, len(id) = %v\n", len(chapterFourFileOrder), len(solutionIds))
82+
fmt.Printf("There are %v files in ChapterFour including _index, len(id) = %v\n", len(chapterFourFileOrder), len(solutionIds))
8383
return chapterFourFileOrder, solutionIds
8484
}
8585

@@ -146,33 +146,33 @@ func addPreNextLabel(order, preOrder []string, chapterFourIds []int, preChapter,
146146
tmp := ""
147147
if index == 0 {
148148
if chapter == "ChapterOne" {
149-
// 第一页不需要“上一章”
150-
tmp = "\n\n" + delLine + fmt.Sprintf("<p align = \"right\"><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">下一页➡️</a></p>\n", chapter, order[index+1])
149+
// The first page does not need a "previous chapter"
150+
tmp = "\n\n" + delLine + fmt.Sprintf("<p align = \"right\"><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">next page➡️</a></p>\n", chapter, order[index+1])
151151
} else {
152152
if chapter == "ChapterFour" {
153-
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">⬅️上一章</a></p>\n", preChapter, preOrder[len(preOrder)-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">下一页➡️</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)+1]), order[index+1]) + preNextFotter
153+
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">⬅️previous chapter</a></p>\n", preChapter, preOrder[len(preOrder)-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">Next page ➡️</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)+1]), order[index+1]) + preNextFotter
154154
} else {
155-
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">⬅️上一章</a></p>\n", preChapter, preOrder[len(preOrder)-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">下一页➡️</a></p>\n", chapter, order[index+1]) + preNextFotter
155+
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">⬅️previous chapter</a></p>\n", preChapter, preOrder[len(preOrder)-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">next page➡️</a></p>\n", chapter, order[index+1]) + preNextFotter
156156
}
157157
}
158158
} else if index == len(order)-1 {
159159
if chapter == "ChapterFour" {
160-
// 最后一页不需要“下一页”
161-
tmp = "\n\n" + delLine + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">⬅️上一页</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)-1]), order[index-1])
160+
// Last page doesn't need "next page"
161+
tmp = "\n\n" + delLine + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">⬅️previous page</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)-1]), order[index-1])
162162
} else {
163-
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">⬅️上一页</a></p>\n", chapter, order[index-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/\">下一章➡️</a></p>\n", nextChapter) + preNextFotter
163+
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">⬅️previous page</a></p>\n", chapter, order[index-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/\">next chapter➡️</a></p>\n", nextChapter) + preNextFotter
164164
}
165165
} else if index == 1 {
166166
if chapter == "ChapterFour" {
167-
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/\">⬅️上一页</a></p>\n", chapter) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">下一页➡️</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)+1]), order[index+1]) + preNextFotter
167+
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/\">⬅️previous page</a></p>\n", chapter) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">next page➡️</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)+1]), order[index+1]) + preNextFotter
168168
} else {
169-
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/\">⬅️上一页</a></p>\n", chapter) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">下一页➡️</a></p>\n", chapter, order[index+1]) + preNextFotter
169+
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/\">⬅️previous page</a></p>\n", chapter) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">next page➡️</a></p>\n", chapter, order[index+1]) + preNextFotter
170170
}
171171
} else {
172172
if chapter == "ChapterFour" {
173-
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">⬅️上一页</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)-1]), order[index-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">下一页➡️</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)+1]), order[index+1]) + preNextFotter
173+
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">⬅️previous page</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)-1]), order[index-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">next page➡️</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)+1]), order[index+1]) + preNextFotter
174174
} else {
175-
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">⬅️上一页</a></p>\n", chapter, order[index-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">下一页➡️</a></p>\n", chapter, order[index+1]) + preNextFotter
175+
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">⬅️previous page</a></p>\n", chapter, order[index-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">next page➡️</a></p>\n", chapter, order[index+1]) + preNextFotter
176176
}
177177
}
178178

@@ -185,7 +185,7 @@ func addPreNextLabel(order, preOrder []string, chapterFourIds []int, preChapter,
185185
fmt.Println(err)
186186
return
187187
}
188-
// 当前没有上一页和下一页,才添加
188+
// There is no previous page and next page, just add
189189
if !exist && err == nil {
190190
res, err = eofAdd(fmt.Sprintf("../website/content/%v/%v.md", chapter, path), tmp)
191191
if err != nil {
@@ -196,7 +196,7 @@ func addPreNextLabel(order, preOrder []string, chapterFourIds []int, preChapter,
196196
count++
197197
}
198198
}
199-
fmt.Printf("添加了 %v 个文件的 pre-next\n", count)
199+
fmt.Printf("Added pre-next of %v files\n", count)
200200
}
201201

202202
func eofAdd(filePath string, labelString string) ([]byte, error) {
@@ -250,14 +250,14 @@ func delPreNextLabel(order []string, chapterFourIds []int, chapter string) {
250250
fmt.Println(err)
251251
return
252252
}
253-
// 存在才删除
253+
// Delete only if it exists
254254
if exist && err == nil {
255255
removeLine(fmt.Sprintf("../website/content/%v/%v.md", chapter, path), lineNum+1)
256256
count++
257257
}
258258
}
259-
fmt.Printf("删除了 %v 个文件的 pre-next\n", count)
260-
// 另外一种删除方法
259+
fmt.Printf("Deleted pre-next of %v files\n", count)
260+
// another way to delete
261261
// res, err := eofDel(fmt.Sprintf("../website/content/ChapterOne/%v.md", v))
262262
// if err != nil {
263263
// fmt.Println(err)

ctl/models/mdrow.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func GenerateMdRows(solutionIds []int, mdrows []Mdrow) {
3535
Frequency: row.Frequency,
3636
}
3737
} else {
38-
fmt.Printf("序号不存在 len(solutionIds) = %v len(mdrows) = %v len(solutionIds) = %v solutionIds[i] = %v QuestionTitle = %v\n", len(solutionIds), len(mdrows), len(solutionIds), solutionIds[i], mdrows[solutionIds[i]-1].QuestionTitle)
38+
fmt.Printf("The serial number does not exist len(solutionIds) = %v len(mdrows) = %v len(solutionIds) = %v solutionIds[i] = %v QuestionTitle = %v\n", len(solutionIds), len(mdrows), len(solutionIds), solutionIds[i], mdrows[solutionIds[i]-1].QuestionTitle)
3939
}
4040
}
4141
for i := range mdrows {
@@ -79,7 +79,7 @@ func (mds Mdrows) table() string {
7979
for _, p := range mds.Mdrows {
8080
res += p.tableLine()
8181
}
82-
// 加这一行是为了撑开整个表格
82+
// Add this line to expand the entire table
8383
res += "|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|"
8484
return res
8585
}

ctl/models/tagproblem.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,27 +125,27 @@ func standardizedTitle(orig string, frontendQuestionID int32) string {
125125
s6 := strings.Replace(s5, ",", "", -1)
126126
s7 := strings.Replace(s6, "?", "", -1)
127127
count := 0
128-
// 去掉 --- 这种情况,这种情况是由于题目标题中包含 - ,左右有空格,左右一填充,造成了 ---,3 个 -
128+
// Remove ---In this case, this is because the title of the topic contains -, there are spaces on the left and right, and one padding on the left and right, resulting in ---, 3 -
129129
for i := 0; i < len(s7)-2; i++ {
130130
if s7[i] == '-' && s7[i+1] == '-' && s7[i+2] == '-' {
131-
fmt.Printf("【需要修正 --- 的标题是 %v\n", fmt.Sprintf("%04d.%v", int(frontendQuestionID), s7))
131+
fmt.Printf("[Fix required ---title is %v]\n", fmt.Sprintf("%04d.%v", int(frontendQuestionID), s7))
132132
s7 = s7[:i+1] + s7[i+3:]
133133
count++
134134
}
135135
}
136136
if count > 0 {
137-
fmt.Printf("总共修正了 %v 个标题\n", count)
137+
fmt.Printf("A total of %v titles were corrected\n", count)
138138
}
139-
// 去掉 -- 这种情况,这种情况是由于题目标题中包含负号 -
139+
// Remove --In this case, this case is due to the minus sign in the title of the question -
140140
for i := 0; i < len(s7)-2; i++ {
141141
if s7[i] == '-' && s7[i+1] == '-' {
142-
fmt.Printf("【需要修正 -- 的标题是 %v\n", fmt.Sprintf("%04d.%v", int(frontendQuestionID), s7))
142+
fmt.Printf("[Needs fix --title is %v]\n", fmt.Sprintf("%04d.%v", int(frontendQuestionID), s7))
143143
s7 = s7[:i+1] + s7[i+2:]
144144
count++
145145
}
146146
}
147147
if count > 0 {
148-
fmt.Printf("总共修正了 %v 个标题\n", count)
148+
fmt.Printf("A total of %v titles were corrected\n", count)
149149
}
150150
return s7
151151
}
@@ -188,7 +188,7 @@ func (tls TagLists) table() string {
188188
for _, p := range tls.TagLists {
189189
res += p.tableLine()
190190
}
191-
// 加这一行是为了撑开整个表格
191+
// Add this line to expand the entire table
192192
res += "|------------|-------------------------------------------------------|-------| ----------------| ---------------|-------------|-------------|-------------|"
193193
return res
194194
}

0 commit comments

Comments
 (0)