Skip to content

Commit ab4c42d

Browse files
authored
Merge pull request #37 from rennzhang/feat-lang
2 parents 5941680 + 68ddb8c commit ab4c42d

14 files changed

+441
-90
lines changed

‎src/codeTemplates/backtrack.js

+31-15
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,62 @@
1+
const { t } = require("../locales");
12
module.exports = () => ({
23
logo: require("../imgs/backtrack.svg"),
3-
title: "回溯",
4+
// title: "回溯",
5+
title: t("Locale.codeTemplate.backtrack.title"),
46
list: [
57
{
6-
text: "标准回溯(伪代码)",
8+
// text: "标准回溯(伪代码)",
9+
text: t("Locale.codeTemplate.backtrack.item1"),
710
problems: [
811
{
912
id: "combination-sum",
10-
title: "39. 组合总和",
13+
// title: "39. 组合总和",
14+
title: t("Locale.problem.39"),
1115
},
1216
{
13-
title: "40. 组合总和 II",
17+
// title: "40. 组合总和 II",
18+
title: t("Locale.problem.40"),
1419
id: "combination-sum-ii",
1520
},
1621
{
17-
title: "46. 全排列",
22+
// title: "46. 全排列",
23+
title: t("Locale.problem.46"),
1824
id: "permutations",
1925
},
2026
{
21-
title: "47. 全排列 II",
27+
// title: "47. 全排列 II",
28+
title: t("Locale.problem.47"),
2229
id: "permutations-ii",
2330
},
2431
{
2532
id: "N-Queens-II",
26-
title: "52. N 皇后 II",
33+
// title: "52. N 皇后 II",
34+
title: t("Locale.problem.52"),
2735
},
2836
{
2937
id: "subsets",
30-
title: "78. 子集",
38+
// title: "78. 子集",
39+
title: t("Locale.problem.78"),
3140
},
3241
{
3342
id: "subsets-ii",
34-
title: "90. 子集 II",
43+
// title: "90. 子集 II",
44+
title: t("Locale.problem.90"),
3545
},
3646
{
3747
id: "path-sum-ii",
38-
title: "113. 路径总和 II",
48+
// title: "113. 路径总和 II",
49+
title: t("Locale.problem.113"),
3950
},
4051
{
4152
id: "palindrome-partitioning",
42-
title: "131. 分割回文串",
53+
// title: "131. 分割回文串",
54+
title: t("Locale.problem.131"),
4355
},
4456
{
4557
id: "maximum-score-words-formed-by-letters",
46-
title: "1255. 得分最高的单词集合",
58+
// title: "1255. 得分最高的单词集合",
59+
title: t("Locale.problem.1255"),
4760
},
4861
],
4962
codes: [
@@ -71,15 +84,18 @@ module.exports = () => ({
7184
],
7285
},
7386
{
74-
text: "笛卡尔积优化",
87+
// text: "笛卡尔积优化",
88+
text: t("Locale.codeTemplate.backtrack.item2"),
7589
problems: [
7690
{
7791
id: "word-break-ii",
78-
title: "140. 单词拆分 II",
92+
// title: "140. 单词拆分 II",
93+
title: t("Locale.problem.140"),
7994
},
8095
{
8196
id: "ambiguous-coordinates",
82-
title: "816. 模糊坐标",
97+
// title: "816. 模糊坐标",
98+
title: t("Locale.problem.816"),
8399
},
84100
],
85101
codes: [

‎src/codeTemplates/bfs.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
import bfsLogo from "../imgs/bfs.svg";
2+
const { t } = require("../locales");
23

34
export default () => ({
45
title: "BFS",
56
logo: bfsLogo,
67
list: [
78
{
8-
text: "带层信息",
9+
// text: "带层信息",
10+
text: t("Locale.codeTemplate.BFS.item1"),
911
problems: [
1012
{
11-
title: "513.找树左下角的值",
13+
// title: "513.找树左下角的值",
14+
title: t("Locale.problem.513"),
1215
id: "find-bottom-left-tree-value",
1316
},
1417
{
15-
title: "662. 二叉树最大宽度",
18+
// title: "662. 二叉树最大宽度",
19+
title: t("Locale.problem.662"),
1620
id: "maximum-width-of-binary-tree",
1721
},
1822
{
19-
title: "863. 二叉树中所有距离为 K 的结点",
23+
// title: "863. 二叉树中所有距离为 K 的结点",
24+
title: t("Locale.problem.863"),
2025
id: "all-nodes-distance-k-in-binary-tree",
2126
},
2227
],
@@ -51,10 +56,12 @@ export default () => ({
5156
],
5257
},
5358
{
54-
text: "不带层信息",
59+
// text: "不带层信息",
60+
text: t("Locale.codeTemplate.BFS.item2"),
5561
problems: [
5662
{
57-
title: "116. 填充每个节点的下一个右侧节点指针",
63+
// title: "116. 填充每个节点的下一个右侧节点指针",
64+
title: t("Locale.problem.116"),
5865
id: "populating-next-right-pointers-in-each-node",
5966
},
6067
],

‎src/codeTemplates/binarySearch.js

+27-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
const { t } = require("../locales");
12
module.exports = () => ({
2-
title: "二分法",
3+
// title: "二分法",
4+
title: t("Locale.codeTemplate.binarySearch.title"),
35
logo: require("../imgs/half.svg"),
46
list: [
57
{
6-
text: "查找一个数",
8+
// text: "查找一个数",
9+
text: t("Locale.codeTemplate.binarySearch.item1"),
710
problems: [
811
{
912
id: "single-element-in-a-sorted-array",
10-
title: "540. 有序数组中的单一元素",
13+
// title: "540. 有序数组中的单一元素",
14+
title: t("Locale.problem.540"),
1115
},
1216
],
1317
codes: [
@@ -92,15 +96,18 @@ module.exports = () => ({
9296
],
9397
},
9498
{
95-
text: "寻找最左边的满足条件的值",
99+
// text: "寻找最左边的满足条件的值",
100+
text: t("Locale.codeTemplate.binarySearch.item2"),
96101
problems: [
97102
{
98103
id: "find-first-and-last-position-of-element-in-sorted-array",
99-
title: "34. 在排序数组中查找元素的第一个和最后一个位置",
104+
// title: "34. 在排序数组中查找元素的第一个和最后一个位置",
105+
title: t("Locale.problem.34"),
100106
},
101107
{
102108
id: "first-bad-version",
103-
title: "278. 第一个错误的版本",
109+
// title: "278. 第一个错误的版本",
110+
title: t("Locale.problem.278"),
104111
},
105112
],
106113
codes: [
@@ -194,15 +201,18 @@ module.exports = () => ({
194201
],
195202
},
196203
{
197-
text: "寻找最右边的满足条件的值",
204+
// text: "寻找最右边的满足条件的值",
205+
text: t("Locale.codeTemplate.binarySearch.item3"),
198206
problems: [
199207
{
200208
id: "find-first-and-last-position-of-element-in-sorted-array",
201-
title: "34. 在排序数组中查找元素的第一个和最后一个位置",
209+
// title: "34. 在排序数组中查找元素的第一个和最后一个位置",
210+
title: t("Locale.problem.34"),
202211
},
203212
{
204213
id: "sqrtx",
205-
title: "69. x 的平方根",
214+
// title: "69. x 的平方根",
215+
title: t("Locale.problem.69"),
206216
},
207217
],
208218
codes: [
@@ -297,7 +307,8 @@ module.exports = () => ({
297307
],
298308
},
299309
{
300-
text: "寻找最左插入位置",
310+
// text: "寻找最左插入位置",
311+
text: t("Locale.codeTemplate.binarySearch.item4"),
301312
codes: [
302313
{
303314
language: "py",
@@ -344,12 +355,14 @@ function searchInsertLeft(nums, x) {
344355
problems: [
345356
{
346357
id: "random-pick-with-weight",
347-
title: "528. 按权重随机选择",
358+
// title: "528. 按权重随机选择",
359+
title: t("Locale.problem.528"),
348360
},
349361
],
350362
},
351363
{
352-
text: "寻找最右插入位置",
364+
// text: "寻找最右插入位置",
365+
text: t("Locale.codeTemplate.binarySearch.item5"),
353366
codes: [
354367
{
355368
language: "py",
@@ -395,7 +408,8 @@ function searchInsertRight(nums, x) {
395408
problems: [
396409
{
397410
id: "find-first-and-last-position-of-element-in-sorted-array",
398-
title: "34. 在排序数组中查找元素的第一个和最后一个位置",
411+
// title: "34. 在排序数组中查找元素的第一个和最后一个位置",
412+
title: t("Locale.problem.34"),
399413
},
400414
],
401415
},

‎src/codeTemplates/hand-writing.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
const { t } = require("../locales");
2+
13
module.exports = () => ({
24
logo: require("../imgs/hand-writing.svg"),
3-
title: "手撕算法",
5+
// title: "手撕算法",
6+
title: t("Locale.codeTemplate.handWriting.title"),
47
list: [
58
{
6-
text: "数组排序",
9+
// text: "数组排序",
10+
text: t("Locale.codeTemplate.handWriting.item1"),
711
problems: [
812
{
913
id: "sort-an-array",
10-
title: "912. 排序数组",
14+
// title: "912. 排序数组",
15+
title: t("Locale.problem.912"),
1116
},
1217
],
1318
codes: [
@@ -160,11 +165,13 @@ class Solution:
160165
],
161166
},
162167
{
163-
text: "链表排序",
168+
// text: "链表排序",
169+
text: t("Locale.codeTemplate.handWriting.item2"),
164170
problems: [
165171
{
166172
id: "sort-list",
167-
title: "148. 排序链表",
173+
// title: "148. 排序链表",
174+
title: t("Locale.problem.148"),
168175
},
169176
],
170177
codes: [

‎src/codeTemplates/heap.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { t } = require("../locales");
2+
13
const minHeapJSCode = `
24
function minHeap(A = []) {
35
this.heapify(A);
@@ -237,13 +239,16 @@ public class MinHeap {
237239
`;
238240
module.exports = () => ({
239241
logo: require("../imgs/heap.svg"),
240-
title: "堆",
242+
// title: "堆",
243+
title: t("Locale.codeTemplate.heap.title"),
241244
list: [
242245
{
243-
text: "小顶堆",
246+
// text: "小顶堆",
247+
text: t("Locale.codeTemplate.heap.item1"),
244248
problems: [
245249
{
246-
title: "1046. 最后一块石头的重量(这道题需要用大顶堆,不过都差不多)",
250+
// title: "1046. 最后一块石头的重量(这道题需要用大顶堆,不过都差不多)",
251+
title: t("Locale.problem.1046"),
247252
id: "last-stone-weight",
248253
},
249254
],

‎src/codeTemplates/prime.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { t } = require("../locales");
2+
13
const pyCode = `
24
MAXN = int(1e5)
35
flag = [True] * (MAXN + 10) # if flag[i] is true, then i is prime
@@ -9,14 +11,17 @@ for i in range(2, int(MAXN ** 0.5) + 1):
911
`;
1012

1113
module.exports = () => ({
12-
title: "求质数",
14+
// title: "求质数",
15+
title: t("Locale.codeTemplate.prime.title"),
1316
// logo: require("../imgs/preSum.svg"),
1417
list: [
1518
{
16-
text: "质数筛选法",
19+
// text: "质数筛选法",
20+
text: t("Locale.codeTemplate.prime.item1"),
1721
problems: [
1822
{
19-
title: "2867. 统计树中的合法路径数目",
23+
// title: "2867. 统计树中的合法路径数目",
24+
title: t("Locale.problem.2867"),
2025
id: "count-valid-paths-in-a-tree",
2126
},
2227
],

‎src/codeTemplates/rotate.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
const { t } = require("../locales");
2+
13
module.exports = () => ({
2-
title: "矩阵旋转",
4+
// title: "矩阵旋转",
5+
title: t("Locale.codeTemplate.rotate.title"),
36
logo: require("../imgs/rotate.svg"),
47
list: [
58
{
6-
text: "顺时针 90° 旋转二维矩阵",
9+
// text: "顺时针 90° 旋转二维矩阵",
10+
text: t("Locale.codeTemplate.rotate.item1"),
711
problems: [
812
{
913
id: "determine-whether-matrix-can-be-obtained-by-rotation",
10-
title: "1886.判断矩阵经轮转后是否一致",
14+
// title: "1886.判断矩阵经轮转后是否一致",
15+
title: t("Locale.problem.1886"),
1116
},
1217
],
1318
codes: [

0 commit comments

Comments
 (0)