Skip to content

feat: i18n update #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions src/codeTemplates/backtrack.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,62 @@
const { t } = require("../locales");
module.exports = () => ({
logo: require("../imgs/backtrack.svg"),
title: "回溯",
// title: "回溯",
title: t("Locale.codeTemplate.backtrack.title"),
list: [
{
text: "标准回溯(伪代码)",
// text: "标准回溯(伪代码)",
text: t("Locale.codeTemplate.backtrack.item1"),
problems: [
{
id: "combination-sum",
title: "39. 组合总和",
// title: "39. 组合总和",
title: t("Locale.problem.39"),
},
{
title: "40. 组合总和 II",
// title: "40. 组合总和 II",
title: t("Locale.problem.40"),
id: "combination-sum-ii",
},
{
title: "46. 全排列",
// title: "46. 全排列",
title: t("Locale.problem.46"),
id: "permutations",
},
{
title: "47. 全排列 II",
// title: "47. 全排列 II",
title: t("Locale.problem.47"),
id: "permutations-ii",
},
{
id: "N-Queens-II",
title: "52. N 皇后 II",
// title: "52. N 皇后 II",
title: t("Locale.problem.52"),
},
{
id: "subsets",
title: "78. 子集",
// title: "78. 子集",
title: t("Locale.problem.78"),
},
{
id: "subsets-ii",
title: "90. 子集 II",
// title: "90. 子集 II",
title: t("Locale.problem.90"),
},
{
id: "path-sum-ii",
title: "113. 路径总和 II",
// title: "113. 路径总和 II",
title: t("Locale.problem.113"),
},
{
id: "palindrome-partitioning",
title: "131. 分割回文串",
// title: "131. 分割回文串",
title: t("Locale.problem.131"),
},
{
id: "maximum-score-words-formed-by-letters",
title: "1255. 得分最高的单词集合",
// title: "1255. 得分最高的单词集合",
title: t("Locale.problem.1255"),
},
],
codes: [
Expand Down Expand Up @@ -71,15 +84,18 @@ module.exports = () => ({
],
},
{
text: "笛卡尔积优化",
// text: "笛卡尔积优化",
text: t("Locale.codeTemplate.backtrack.item2"),
problems: [
{
id: "word-break-ii",
title: "140. 单词拆分 II",
// title: "140. 单词拆分 II",
title: t("Locale.problem.140"),
},
{
id: "ambiguous-coordinates",
title: "816. 模糊坐标",
// title: "816. 模糊坐标",
title: t("Locale.problem.816"),
},
],
codes: [
Expand Down
19 changes: 13 additions & 6 deletions src/codeTemplates/bfs.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
import bfsLogo from "../imgs/bfs.svg";
const { t } = require("../locales");

export default () => ({
title: "BFS",
logo: bfsLogo,
list: [
{
text: "带层信息",
// text: "带层信息",
text: t("Locale.codeTemplate.BFS.item1"),
problems: [
{
title: "513.找树左下角的值",
// title: "513.找树左下角的值",
title: t("Locale.problem.513"),
id: "find-bottom-left-tree-value",
},
{
title: "662. 二叉树最大宽度",
// title: "662. 二叉树最大宽度",
title: t("Locale.problem.662"),
id: "maximum-width-of-binary-tree",
},
{
title: "863. 二叉树中所有距离为 K 的结点",
// title: "863. 二叉树中所有距离为 K 的结点",
title: t("Locale.problem.863"),
id: "all-nodes-distance-k-in-binary-tree",
},
],
Expand Down Expand Up @@ -51,10 +56,12 @@ export default () => ({
],
},
{
text: "不带层信息",
// text: "不带层信息",
text: t("Locale.codeTemplate.BFS.item2"),
problems: [
{
title: "116. 填充每个节点的下一个右侧节点指针",
// title: "116. 填充每个节点的下一个右侧节点指针",
title: t("Locale.problem.116"),
id: "populating-next-right-pointers-in-each-node",
},
],
Expand Down
40 changes: 27 additions & 13 deletions src/codeTemplates/binarySearch.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
const { t } = require("../locales");
module.exports = () => ({
title: "二分法",
// title: "二分法",
title: t("Locale.codeTemplate.binarySearch.title"),
logo: require("../imgs/half.svg"),
list: [
{
text: "查找一个数",
// text: "查找一个数",
text: t("Locale.codeTemplate.binarySearch.item1"),
problems: [
{
id: "single-element-in-a-sorted-array",
title: "540. 有序数组中的单一元素",
// title: "540. 有序数组中的单一元素",
title: t("Locale.problem.540"),
},
],
codes: [
Expand Down Expand Up @@ -92,15 +96,18 @@ module.exports = () => ({
],
},
{
text: "寻找最左边的满足条件的值",
// text: "寻找最左边的满足条件的值",
text: t("Locale.codeTemplate.binarySearch.item2"),
problems: [
{
id: "find-first-and-last-position-of-element-in-sorted-array",
title: "34. 在排序数组中查找元素的第一个和最后一个位置",
// title: "34. 在排序数组中查找元素的第一个和最后一个位置",
title: t("Locale.problem.34"),
},
{
id: "first-bad-version",
title: "278. 第一个错误的版本",
// title: "278. 第一个错误的版本",
title: t("Locale.problem.278"),
},
],
codes: [
Expand Down Expand Up @@ -194,15 +201,18 @@ module.exports = () => ({
],
},
{
text: "寻找最右边的满足条件的值",
// text: "寻找最右边的满足条件的值",
text: t("Locale.codeTemplate.binarySearch.item3"),
problems: [
{
id: "find-first-and-last-position-of-element-in-sorted-array",
title: "34. 在排序数组中查找元素的第一个和最后一个位置",
// title: "34. 在排序数组中查找元素的第一个和最后一个位置",
title: t("Locale.problem.34"),
},
{
id: "sqrtx",
title: "69. x 的平方根",
// title: "69. x 的平方根",
title: t("Locale.problem.69"),
},
],
codes: [
Expand Down Expand Up @@ -297,7 +307,8 @@ module.exports = () => ({
],
},
{
text: "寻找最左插入位置",
// text: "寻找最左插入位置",
text: t("Locale.codeTemplate.binarySearch.item4"),
codes: [
{
language: "py",
Expand Down Expand Up @@ -344,12 +355,14 @@ function searchInsertLeft(nums, x) {
problems: [
{
id: "random-pick-with-weight",
title: "528. 按权重随机选择",
// title: "528. 按权重随机选择",
title: t("Locale.problem.528"),
},
],
},
{
text: "寻找最右插入位置",
// text: "寻找最右插入位置",
text: t("Locale.codeTemplate.binarySearch.item5"),
codes: [
{
language: "py",
Expand Down Expand Up @@ -395,7 +408,8 @@ function searchInsertRight(nums, x) {
problems: [
{
id: "find-first-and-last-position-of-element-in-sorted-array",
title: "34. 在排序数组中查找元素的第一个和最后一个位置",
// title: "34. 在排序数组中查找元素的第一个和最后一个位置",
title: t("Locale.problem.34"),
},
],
},
Expand Down
17 changes: 12 additions & 5 deletions src/codeTemplates/hand-writing.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
const { t } = require("../locales");

module.exports = () => ({
logo: require("../imgs/hand-writing.svg"),
title: "手撕算法",
// title: "手撕算法",
title: t("Locale.codeTemplate.handWriting.title"),
list: [
{
text: "数组排序",
// text: "数组排序",
text: t("Locale.codeTemplate.handWriting.item1"),
problems: [
{
id: "sort-an-array",
title: "912. 排序数组",
// title: "912. 排序数组",
title: t("Locale.problem.912"),
},
],
codes: [
Expand Down Expand Up @@ -160,11 +165,13 @@ class Solution:
],
},
{
text: "链表排序",
// text: "链表排序",
text: t("Locale.codeTemplate.handWriting.item2"),
problems: [
{
id: "sort-list",
title: "148. 排序链表",
// title: "148. 排序链表",
title: t("Locale.problem.148"),
},
],
codes: [
Expand Down
11 changes: 8 additions & 3 deletions src/codeTemplates/heap.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { t } = require("../locales");

const minHeapJSCode = `
function minHeap(A = []) {
this.heapify(A);
Expand Down Expand Up @@ -237,13 +239,16 @@ public class MinHeap {
`;
module.exports = () => ({
logo: require("../imgs/heap.svg"),
title: "堆",
// title: "堆",
title: t("Locale.codeTemplate.heap.title"),
list: [
{
text: "小顶堆",
// text: "小顶堆",
text: t("Locale.codeTemplate.heap.item1"),
problems: [
{
title: "1046. 最后一块石头的重量(这道题需要用大顶堆,不过都差不多)",
// title: "1046. 最后一块石头的重量(这道题需要用大顶堆,不过都差不多)",
title: t("Locale.problem.1046"),
id: "last-stone-weight",
},
],
Expand Down
11 changes: 8 additions & 3 deletions src/codeTemplates/prime.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { t } = require("../locales");

const pyCode = `
MAXN = int(1e5)
flag = [True] * (MAXN + 10) # if flag[i] is true, then i is prime
Expand All @@ -9,14 +11,17 @@ for i in range(2, int(MAXN ** 0.5) + 1):
`;

module.exports = () => ({
title: "求质数",
// title: "求质数",
title: t("Locale.codeTemplate.prime.title"),
// logo: require("../imgs/preSum.svg"),
list: [
{
text: "质数筛选法",
// text: "质数筛选法",
text: t("Locale.codeTemplate.prime.item1"),
problems: [
{
title: "2867. 统计树中的合法路径数目",
// title: "2867. 统计树中的合法路径数目",
title: t("Locale.problem.2867"),
id: "count-valid-paths-in-a-tree",
},
],
Expand Down
11 changes: 8 additions & 3 deletions src/codeTemplates/rotate.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
const { t } = require("../locales");

module.exports = () => ({
title: "矩阵旋转",
// title: "矩阵旋转",
title: t("Locale.codeTemplate.rotate.title"),
logo: require("../imgs/rotate.svg"),
list: [
{
text: "顺时针 90° 旋转二维矩阵",
// text: "顺时针 90° 旋转二维矩阵",
text: t("Locale.codeTemplate.rotate.item1"),
problems: [
{
id: "determine-whether-matrix-can-be-obtained-by-rotation",
title: "1886.判断矩阵经轮转后是否一致",
// title: "1886.判断矩阵经轮转后是否一致",
title: t("Locale.problem.1886"),
},
],
codes: [
Expand Down
Loading