From e89ac34dfa6c9b763d7f7924080d1975b0e4f577 Mon Sep 17 00:00:00 2001 From: Renkin <906155099@qq.com> Date: Wed, 1 Nov 2023 22:05:39 +0800 Subject: [PATCH 1/8] feat: update i18n --- src/codeTemplates/codeTemplate.jsx | 2 +- src/locales/en.js | 2 +- src/locales/zh.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/codeTemplates/codeTemplate.jsx b/src/codeTemplates/codeTemplate.jsx index a5233ab..3a7ada7 100644 --- a/src/codeTemplates/codeTemplate.jsx +++ b/src/codeTemplates/codeTemplate.jsx @@ -74,7 +74,7 @@ export default function CodeTemplate({ templates }) { size="small" style={{ marginLeft: "10px" }} > - {t("Locale.app.toWriteSilently")} + {t("Locale.app.goForDictation")} ))} diff --git a/src/locales/en.js b/src/locales/en.js index 12db0b7..fa5c68e 100644 --- a/src/locales/en.js +++ b/src/locales/en.js @@ -6,7 +6,7 @@ export const en = { copySuccess: "Copy successfully~", article: "article", recommendedQuestions: "Recommended Questions:", - toWriteSilently: "To write silently", + goForDictation: "go for dictation", contribution: "Correction or contribution to other languages", back: "Back to Home page", viewSolution: "View solution", diff --git a/src/locales/zh.js b/src/locales/zh.js index 4dee4a9..9d5c59f 100644 --- a/src/locales/zh.js +++ b/src/locales/zh.js @@ -7,7 +7,7 @@ export const cn = { copySuccess: "复制成功~", article: "文章", recommendedQuestions: "推荐题目:", - toWriteSilently: "去默写", + goForDictation: "去默写", contribution:"纠错 or 贡献其他语言", back: "返回主页", viewSolution: "查看本题题解", From 55d8fbb816d422759aca37437e8233a2daf05c5f Mon Sep 17 00:00:00 2001 From: Renkin <906155099@qq.com> Date: Fri, 3 Nov 2023 10:55:46 +0800 Subject: [PATCH 2/8] fix: Fixed not being able to click Toggle tab in codeTemplate --- src/codeTemplates/codeTemplate.jsx | 2 +- src/codeTemplates/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codeTemplates/codeTemplate.jsx b/src/codeTemplates/codeTemplate.jsx index 3a7ada7..aa894a3 100644 --- a/src/codeTemplates/codeTemplate.jsx +++ b/src/codeTemplates/codeTemplate.jsx @@ -28,7 +28,7 @@ export default function CodeTemplate({ templates }) { return (
- + {tempaltesState.map((tempalte) => ( Date: Fri, 3 Nov 2023 11:15:07 +0800 Subject: [PATCH 3/8] fix: Fixed the issue of content not rendering directly into the website --- src/App.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/App.js b/src/App.js index 1967262..31972e7 100644 --- a/src/App.js +++ b/src/App.js @@ -1,4 +1,4 @@ -import React, { useState, Suspense } from "react"; +import React, { useState, Suspense, useEffect } from "react"; import { Button, Table, Empty, Tabs, Image } from "antd"; import "highlight.js/styles/github.css"; @@ -109,8 +109,8 @@ function App() { // setHasSolution(!!problems[problemId]); // }, 1000); - // 开发环境不需要依赖 chrome 插件 query 函数 - const [langReady, setLangReady] = useState(isDev); + // 开发环境和直接进入网站的方式不需要依赖 chrome 插件 query 函数 + const [langReady, setLangReady] = useState(isDev||!isInExtension()); const [problemId, setProblemId] = useState(""); const [hasSolution, setHasSolution] = useState(false); @@ -243,7 +243,7 @@ function App() { From b925075deccceba3740865aba02f189df84f840f Mon Sep 17 00:00:00 2001 From: Renkin <906155099@qq.com> Date: Fri, 3 Nov 2023 11:16:18 +0800 Subject: [PATCH 4/8] feat: update i18n(complexityRating & dataStructureVis) --- src/complexityRating/index.jsx | 12 +-- src/dataStructureVis/data.js | 178 +++++++++++++++++++++++++++++++++ src/dataStructureVis/index.jsx | 171 +++++++++---------------------- src/locales/en.js | 21 ++++ src/locales/zh.js | 43 +++++--- 5 files changed, 283 insertions(+), 142 deletions(-) create mode 100644 src/dataStructureVis/data.js diff --git a/src/complexityRating/index.jsx b/src/complexityRating/index.jsx index bc05daf..d590f79 100644 --- a/src/complexityRating/index.jsx +++ b/src/complexityRating/index.jsx @@ -1,6 +1,6 @@ import React from "react"; import { Button, Table } from "antd"; - +import { t } from "../locales"; import "./index.less"; // | 数据规模 | 算法可接受时间复杂度 | @@ -15,17 +15,17 @@ import "./index.less"; // | <=10^14 | $O(\sqrt{n})$ | // | - | $O(logn)$ | -const columns = [ +const getColumns = () => [ { key: "size", dataIndex: "size", - title: "数据规模", + title: t("Locale.complexityQuickCheck.dataScale"), align: "center", }, { key: "complexity", dataIndex: "complexity", - title: "算法可接受时间复杂度", + title: t("Locale.complexityQuickCheck.timeComplexity"), align: "center", render: (t) => { if (t === "O(sqrt(n))") @@ -82,10 +82,10 @@ export default function ComplexityRating() { href="https://lucifer.ren/blog/2020/12/21/shuati-silu3/" target="_blank" > - 不懂为什么?点这里 + {t("Locale.complexityQuickCheck.tips")} - +
); } diff --git a/src/dataStructureVis/data.js b/src/dataStructureVis/data.js new file mode 100644 index 0000000..6bd1a09 --- /dev/null +++ b/src/dataStructureVis/data.js @@ -0,0 +1,178 @@ +import treeLevel2 from "../db/dataStructureVis/tree-level-2"; +import treeLevel3 from "../db/dataStructureVis/tree-level-3"; +import treeLevel4 from "../db/dataStructureVis/tree-level-4"; +import trigeminal from "../db/dataStructureVis/trigeminal"; +import graph1 from "../db/dataStructureVis/graph-1"; +import recurTree1 from "../db/dataStructureVis/recur-tree-1.js"; +import array1 from "../db/dataStructureVis/array-1.js"; +import board1 from "../db/dataStructureVis/board-1.js"; +import official from "../db/dataStructureVis/leetcode-official"; +import calm from "../db/dataStructureVis/calm"; + +export const initialDataSource = { + presets: [ + { + title: "力扣官方", + data: official, + desc: "力扣官方题解主题(持续更新)", + type: "leetcode-official", + typeName: "力扣官方", + }, + { + title: "calm", + data: calm, + desc: "稳重色系(目前只完成了树,后续更新其他数据结构)", + type: "theme", + typeName: "色系", + }, + { + title: "二层二叉树", + data: treeLevel2, + desc: "", + cover: "", + type: "tree", + typeName: "树", + }, + { + title: "三层二叉树", + data: treeLevel3, + desc: "", + cover: "", + type: "tree", + typeName: "树", + }, + { + title: "四层二叉树", + data: treeLevel4, + desc: "", + cover: "", + type: "tree", + typeName: "树", + }, + { + title: "三叉树", + data: trigeminal, + desc: "", + cover: "", + type: "tree", + typeName: "树", + }, + { + title: "递归树", + data: recurTree1, + desc: "", + cover: "", + type: "tree", + typeName: "树", + }, + { + title: "简单数组", + data: array1, + desc: "", + cover: "", + type: "array", + typeName: "数组", + }, + { + title: "简单二维矩阵", + data: board1, + desc: "", + cover: "", + type: "board", + typeName: "二维矩阵(或邻接矩阵)", + }, + { + title: "简单图", + data: graph1, + desc: "", + cover: "", + type: "graph", + typeName: "图", + }, + ], + custom: [], + }; + + export const initialDataSourceEn = { + presets: [ + { + title: "LeetCode Official", + data: official, + desc: "Official LeetCode solution topics (continuously updated)", + type: "leetcode-official", + typeName: "LeetCode Official", + }, + { + title: "Calm", + data: calm, + desc: "Serene color scheme (currently only completed for trees, more data structures to be updated)", + type: "theme", + typeName: "Color Scheme", + }, + { + title: "Binary Tree - Level 2", + data: treeLevel2, + desc: "", + cover: "", + type: "tree", + typeName: "Tree", + }, + { + title: "Binary Tree - Level 3", + data: treeLevel3, + desc: "", + cover: "", + type: "tree", + typeName: "Tree", + }, + { + title: "Binary Tree - Level 4", + data: treeLevel4, + desc: "", + cover: "", + type: "tree", + typeName: "Tree", + }, + { + title: "Ternary Tree", + data: trigeminal, + desc: "", + cover: "", + type: "tree", + typeName: "Tree", + }, + { + title: "Recursive Tree", + data: recurTree1, + desc: "", + cover: "", + type: "tree", + typeName: "Tree", + }, + { + title: "Simple Array", + data: array1, + desc: "", + cover: "", + type: "array", + typeName: "Array", + }, + { + title: "Simple 2D Matrix", + data: board1, + desc: "", + cover: "", + type: "board", + typeName: "2D Matrix (or Adjacency Matrix)", + }, + { + title: "Simple Graph", + data: graph1, + desc: "", + cover: "", + type: "graph", + typeName: "Graph", + }, + ], + custom: [], + }; \ No newline at end of file diff --git a/src/dataStructureVis/index.jsx b/src/dataStructureVis/index.jsx index 7fbbca1..6132992 100644 --- a/src/dataStructureVis/index.jsx +++ b/src/dataStructureVis/index.jsx @@ -15,16 +15,8 @@ import { Menu, } from "antd"; import { uuidv4, getStorage, setStorage } from "../utils"; -import treeLevel2 from "../db/dataStructureVis/tree-level-2"; -import treeLevel3 from "../db/dataStructureVis/tree-level-3"; -import treeLevel4 from "../db/dataStructureVis/tree-level-4"; -import trigeminal from "../db/dataStructureVis/trigeminal"; -import graph1 from "../db/dataStructureVis/graph-1"; -import recurTree1 from "../db/dataStructureVis/recur-tree-1.js"; -import array1 from "../db/dataStructureVis/array-1.js"; -import board1 from "../db/dataStructureVis/board-1.js"; -import official from "../db/dataStructureVis/leetcode-official"; -import calm from "../db/dataStructureVis/calm"; +import { initialDataSource, initialDataSourceEn } from "./data"; +import { t, lang } from "../locales"; // import treeLevel5 from "../db/dataStructureVis/tree-level-5"; @@ -54,7 +46,7 @@ function saveScene({ title, elements, customTypeName }) { ) .then(() => { message.success({ - content: "保存成功~", + content: t("app.saveSuccess"), }); return getStorage("customDrawings").then((res) => { const { result } = res; @@ -83,7 +75,7 @@ function deleteCustomDrawing(id) { ) .then(() => { message.success({ - content: "删除成功~", + content: t("app.deleteSuccess"), }); return getStorage("customDrawings").then((res) => { const { result } = res; @@ -94,90 +86,6 @@ function deleteCustomDrawing(id) { }); } -const initialDataSource = { - presets: [ - { - title: "力扣官方", - data: official, - desc: "力扣官方题解主题(持续更新)", - type: "leetcode-official", - typeName: "力扣官方", - }, - { - title: "calm", - data: calm, - desc: "稳重色系(目前只完成了树,后续更新其他数据结构)", - type: "theme", - typeName: "色系", - }, - { - title: "二层二叉树", - data: treeLevel2, - desc: "", - cover: "", - type: "tree", - typeName: "树", - }, - { - title: "三层二叉树", - data: treeLevel3, - desc: "", - cover: "", - type: "tree", - typeName: "树", - }, - { - title: "四层二叉树", - data: treeLevel4, - desc: "", - cover: "", - type: "tree", - typeName: "树", - }, - { - title: "三叉树", - data: trigeminal, - desc: "", - cover: "", - type: "tree", - typeName: "树", - }, - { - title: "递归树", - data: recurTree1, - desc: "", - cover: "", - type: "tree", - typeName: "树", - }, - { - title: "简单数组", - data: array1, - desc: "", - cover: "", - type: "array", - typeName: "数组", - }, - { - title: "简单二维矩阵", - data: board1, - desc: "", - cover: "", - type: "board", - typeName: "二维矩阵(或邻接矩阵)", - }, - { - title: "简单图", - data: graph1, - desc: "", - cover: "", - type: "graph", - typeName: "图", - }, - ], - custom: [], -}; - const excalidrawRef = createRef(); const excalidrawWrapperRef = createRef(); export default function DataStrutureVis() { @@ -197,7 +105,9 @@ export default function DataStrutureVis() { const [activeKey, setActiveKey] = useState("template"); const [elements, setElements] = useState([]); const [title, setTitle] = useState("无标题"); - const [dataSource, setDataSource] = useState(initialDataSource); + const [dataSource, setDataSource] = useState( + lang === "en" ? initialDataSourceEn : initialDataSource + ); const [modalVisible, setModalVisible] = useState(false); const [fullScreenMode, setFullScreenMode] = useState(false); const [customTypeName, setCustomTypeName] = useState("自定义"); @@ -208,8 +118,9 @@ export default function DataStrutureVis() { height: window.innerHeight, }); }; - + console.log("lang", lang); useEffect(() => { + console.log("lang", lang); window.addEventListener("resize", onResize); document.onfullscreenchange = (e) => { const fullscreenElement = document.fullscreenElement; @@ -263,22 +174,27 @@ export default function DataStrutureVis() { setActiveKey(v[0]); }} > - -
+
  1. - 暂不支持编辑功能。如果需要编辑,可通过先“使用”再“保存”,最后“删除”原有的数据,从而间接实现。 + {t("Locale.dataStructureVisualization.explain1")} +
  2. +
  3. + {t("Locale.dataStructureVisualization.explain2")} +
  4. - 模板可以增量使用。点击”去使用“的下拉三角,并选择增量使用即可。 + {t("Locale.dataStructureVisualization.explain3")} +
  5. - 使用的模板会根据你鼠标的位置生成。比如你的鼠标在点(100, - 100),那么模板会整体偏移 (100, 100)个单位 - 。如果此时模板并不是正好以(100, - 100)为左上顶点,说明模板本身制作的时候就不是以(0,0)为左上顶点制作的。大家制作自定义模板的话需要注意这一点。 + {t("Locale.dataStructureVisualization.explain4")} + + Website
  6. -
  7. 你也可以选择直接使用原生 excalidraw 地址
{/* - - + + } bordered @@ -339,7 +255,7 @@ export default function DataStrutureVis() { renderItem={(item) => ( {item.typeName && ( - 【{item.typeName}】 + 【{item.typeName}】 )} {item.title} - 增量使用 + + {t( + "Locale.dataStructureVisualization.incrementalUsage" + )} + } > - {/* @@ -413,7 +333,7 @@ export default function DataStrutureVis() { className="update-scene" onClick={() => setModalVisible(true)} > - 保存 + {t("app.save")} {/* */}
- -
+
{ setPointer(pointer); }} - name="力扣加加" - // user={{ name: "力扣加加" }} - // onPointerUpdate={(payload) => console.log(payload)} + name={t("app.name")} + // user={{ name: "力扣加加" }} + // onPointerUpdate={(payload) => console.log(payload)} />
diff --git a/src/locales/en.js b/src/locales/en.js index fa5c68e..2706fc6 100644 --- a/src/locales/en.js +++ b/src/locales/en.js @@ -1,8 +1,20 @@ export const en = { app: { + name: "LeetCode Cheatsheet", + fullScreen: "Full Screen (Press ESC to exit)", + toUse: "To Use", + custom: "Custom", + presets: "Presets", setLang: "Set Language", changeLang: "中文", copy: "copy", + save: "save", + yes: "yes", + no: "no", + delete: "delete", + delTitle: "Are you sure you want to delete it?", + deleteSuccess: "Delete successfully~", + saveSuccess: "Save successfully~", copySuccess: "Copy successfully~", article: "article", recommendedQuestions: "Recommended Questions:", @@ -78,6 +90,12 @@ export const en = { }, dataStructureVisualization: { name: "Data Structure Visualization", + incrementalUsage: "Incremental Usage", + explain1: + "The editing function is not supported. If you need to edit, you can do so indirectly by first \"use\", then \"save\", and finally \"delete\" the original data.", + explain2: "Templates can be used incrementally. Click the drop-down triangle of 'to use' and select Incremental Usage.", + explain3: "The template will be generated according to the position of your mouse. For example, if your mouse is at point (100, 100), the template will be offset by (100, 100) units as a whole. If the template is not exactly at (100, 100), it means that the template itself was not created with (0, 0) as the top-left corner. When creating custom templates, it's important to keep this in mind.", + explain4: "You can also choose to use the native excalidraw directly ", }, explanationTemplate: { @@ -85,6 +103,9 @@ export const en = { }, complexityQuickCheck: { name: "Complexity Quick Check", + tips: "Don't understand why? Click here", + dataScale: "Data Scale", + timeComplexity: "Algorithm acceptable time complexity", }, learningRoute: { name: "Learning Route", diff --git a/src/locales/zh.js b/src/locales/zh.js index 9d5c59f..ba223f3 100644 --- a/src/locales/zh.js +++ b/src/locales/zh.js @@ -1,14 +1,25 @@ export const cn = { - app: { + name: "力扣加加", + fullScreen: "全屏模式(退出请按 ESC)", + toUse: "去使用", + custom: "自定义", + presets: "预设", setLang: "设置语言", changeLang: "English", copy: "复制", + save: "保存", + yes: "是", + no: "否", + delete: "删除", + delTitle: "确认要删除么?", + deleteSuccess: "删除成功~", + saveSuccess: "保存成功~", copySuccess: "复制成功~", article: "文章", recommendedQuestions: "推荐题目:", goForDictation: "去默写", - contribution:"纠错 or 贡献其他语言", + contribution: "纠错 or 贡献其他语言", back: "返回主页", viewSolution: "查看本题题解", viewInHandpickCollection: "该题已被收录到精选合集《{slotText}》点击查看", @@ -27,7 +38,7 @@ export const cn = { tag: "标签", }, }, - initializeContentScriptFailed:"初始化 chrome 插件 content script 失败", + initializeContentScriptFailed: "初始化 chrome 插件 content script 失败", run: "运行", submit: "提交", wirteSolution: "写题解", @@ -43,13 +54,13 @@ export const cn = { "使用 Github API 失败,已为您切换为普通模式,普通模式仅可自动带入题目名称,题目地址以及题解语言。", }, problem: { - "743": "743. 网络延迟时间", - "1109": "1109. 航班预订统计", - "1314": "1314. 矩阵区域和", - "1462":"1462. 课程表 IV", - "1480": "1480. 一维数组的动态和", - "1584":"1584. 连接所有点的最小费用", - "2536": "2536. 子矩阵元素加 1", + 743: "743. 网络延迟时间", + 1109: "1109. 航班预订统计", + 1314: "1314. 矩阵区域和", + 1462: "1462. 课程表 IV", + 1480: "1480. 一维数组的动态和", + 1584: "1584. 连接所有点的最小费用", + 2536: "2536. 子矩阵元素加 1", }, codeTemplate: { name: "代码模板", @@ -69,13 +80,18 @@ export const cn = { item4: "Kruskal(又称加边法,是一种最小生成树算法)", item5: "Prim(又称加点法,是一种最小生成树算法)", item6: "Kahn(基于BFS的拓扑排序)", - }, - moreTemplate:"更多模板后续陆续更新~" + moreTemplate: "更多模板后续陆续更新~", }, dataStructureVisualization: { name: "数据结构可视化", + incrementalUsage: "增量使用", + explain1: + "暂不支持编辑功能。如果需要编辑,可通过先“使用”再“保存”,最后“删除”原有的数据,从而间接实现。", + explain2: "模板可以增量使用。点击”去使用“的下拉三角,并选择增量使用即可。", + explain3: "使用的模板会根据你鼠标的位置生成。比如你的鼠标在点(100, 100),那么模板会整体偏移 (100, 100)个单位。如果此时模板并不是正好以(100, 100)为左上顶点,说明模板本身制作的时候就不是以(0,0)为左上顶点制作的。大家制作自定义模板的话需要注意这一点。", + explain4: "你也可以选择直接使用原生 excalidraw ", }, explanationTemplate: { @@ -83,6 +99,9 @@ export const cn = { }, complexityQuickCheck: { name: "复杂度速查", + tips: "不懂为什么?点这里", + dataScale: "数据规模", + timeComplexity: "算法可接受时间复杂度", }, learningRoute: { name: "学习路线", From 3a2122101fee6567f6c42008bc25fff1a4c97388 Mon Sep 17 00:00:00 2001 From: Renkin <906155099@qq.com> Date: Fri, 3 Nov 2023 11:48:19 +0800 Subject: [PATCH 5/8] feat: Preserve the original content --- src/complexityRating/index.jsx | 3 +++ src/dataStructureVis/index.jsx | 14 ++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/complexityRating/index.jsx b/src/complexityRating/index.jsx index d590f79..a159ef1 100644 --- a/src/complexityRating/index.jsx +++ b/src/complexityRating/index.jsx @@ -19,12 +19,14 @@ const getColumns = () => [ { key: "size", dataIndex: "size", + // title: "数据规模", title: t("Locale.complexityQuickCheck.dataScale"), align: "center", }, { key: "complexity", dataIndex: "complexity", + // title: "算法可接受时间复杂度", title: t("Locale.complexityQuickCheck.timeComplexity"), align: "center", render: (t) => { @@ -82,6 +84,7 @@ export default function ComplexityRating() { href="https://lucifer.ren/blog/2020/12/21/shuati-silu3/" target="_blank" > + {/* 不懂为什么?点这里 */} {t("Locale.complexityQuickCheck.tips")} diff --git a/src/dataStructureVis/index.jsx b/src/dataStructureVis/index.jsx index 6132992..6855b67 100644 --- a/src/dataStructureVis/index.jsx +++ b/src/dataStructureVis/index.jsx @@ -180,18 +180,24 @@ export default function DataStrutureVis() { >
  1. + {/* 暂不支持编辑功能。如果需要编辑,可通过先“使用”再“保存”,最后“删除”原有的数据,从而间接实现。 */} {t("Locale.dataStructureVisualization.explain1")}
  2. - {t("Locale.dataStructureVisualization.explain2")} + {/* 模板可以增量使用。点击”去使用“的下拉三角,并选择增量使用即可。 */} + {t("Locale.dataStructureVisualization.explain2")}
  3. - {t("Locale.dataStructureVisualization.explain3")} - + {/* 使用的模板会根据你鼠标的位置生成。比如你的鼠标在点(100, + 100),那么模板会整体偏移 (100, 100)个单位 + 。如果此时模板并不是正好以(100, + 100)为左上顶点,说明模板本身制作的时候就不是以(0,0)为左上顶点制作的。大家制作自定义模板的话需要注意这一点。 */} + {t("Locale.dataStructureVisualization.explain3")}
  4. - {t("Locale.dataStructureVisualization.explain4")} + {/* 你也可以选择直接使用原生 excalidraw */} + {t("Locale.dataStructureVisualization.explain4")} Website
  5. From 1c96a9bec775426dab3144f011b40a229e4cf860 Mon Sep 17 00:00:00 2001 From: Renkin <906155099@qq.com> Date: Mon, 6 Nov 2023 17:53:03 +0800 Subject: [PATCH 6/8] feat: i18n update --- src/locales/en.js | 37 +++++++- src/locales/zh.js | 29 +++++- src/roadmap/roadmap.jsx | 2 +- src/solutionTemplate/index.jsx | 158 ++++++++++++++++++++------------- 4 files changed, 156 insertions(+), 70 deletions(-) diff --git a/src/locales/en.js b/src/locales/en.js index 2706fc6..804fdd2 100644 --- a/src/locales/en.js +++ b/src/locales/en.js @@ -1,6 +1,8 @@ -export const en = { +const en = { app: { name: "LeetCode Cheatsheet", + preview: "Preview", + copyMdOrigin: "Click to copy MarkDown origin", fullScreen: "Full Screen (Press ESC to exit)", toUse: "To Use", custom: "Custom", @@ -55,6 +57,7 @@ export const en = { savingProblem: "Saving problem information, please wait~", githubAPIError: "Failed to use Github API, has been switched to normal mode, normal mode can only automatically bring in the problem name, problem address and solution language.", + notYet: "Not yet", }, problem: { 743: "743. Network Delay Time", @@ -93,13 +96,38 @@ export const en = { incrementalUsage: "Incremental Usage", explain1: "The editing function is not supported. If you need to edit, you can do so indirectly by first \"use\", then \"save\", and finally \"delete\" the original data.", - explain2: "Templates can be used incrementally. Click the drop-down triangle of 'to use' and select Incremental Usage.", - explain3: "The template will be generated according to the position of your mouse. For example, if your mouse is at point (100, 100), the template will be offset by (100, 100) units as a whole. If the template is not exactly at (100, 100), it means that the template itself was not created with (0, 0) as the top-left corner. When creating custom templates, it's important to keep this in mind.", + explain2: + "Templates can be used incrementally. Click the drop-down triangle of 'to use' and select Incremental Usage.", + explain3: + "The template will be generated according to the position of your mouse. For example, if your mouse is at point (100, 100), the template will be offset by (100, 100) units as a whole. If the template is not exactly at (100, 100), it means that the template itself was not created with (0, 0) as the top-left corner. When creating custom templates, it's important to keep this in mind.", explain4: "You can also choose to use the native excalidraw directly ", }, explanationTemplate: { name: "Explanation Template", + goToTheWebsiteToUse: "Go to the website to use", + problemAddress: "Problem Address", + problemDesc: "Problem Description", + preKnowledge: "Pre Knowledge", + company: "Company", + thinking: "Thinking", + keyPoints: "Key Points", + languageSupport: "Language Support", + complexityAnalysis: "Complexity Analysis", + complexityDeclare: "Let n be the length of the array.", + timeComplexity: "Time Complexity", + spaceComplexity: "Space Complexity", + howToUse: "How to use it?", + programmingLanguage: "Programming Language:", + commonFormulas: "Common formulas (click to copy):", + noBackup: "No backup file found", + restore: "Restore last edit content", + backupTips: + "The explanation is backed up every five seconds. If you accidentally refresh the browser, you can click the restore button below to restore it. Since it is an overwrite backup, only the last edited content will be saved.", + afterUpdateTemplateTips: + "More explanation templates will be provided later.", + afterUpdateThemeTips: + "More themes and user-defined themes will be supported later.", }, complexityQuickCheck: { name: "Complexity Quick Check", @@ -117,4 +145,5 @@ export const en = { name: "About Me", }, }; -export default en; +// export default en; +module.exports = en; diff --git a/src/locales/zh.js b/src/locales/zh.js index ba223f3..b119c5b 100644 --- a/src/locales/zh.js +++ b/src/locales/zh.js @@ -1,6 +1,8 @@ -export const cn = { +const zh = { app: { name: "力扣加加", + preview: "预览", + copyMdOrigin:"点击复制 MarkDown 原文", fullScreen: "全屏模式(退出请按 ESC)", toUse: "去使用", custom: "自定义", @@ -52,6 +54,7 @@ export const cn = { savingProblem: "正在存储题目信息,请稍后~", githubAPIError: "使用 Github API 失败,已为您切换为普通模式,普通模式仅可自动带入题目名称,题目地址以及题解语言。", + notYet:"暂无", }, problem: { 743: "743. 网络延迟时间", @@ -96,6 +99,27 @@ export const cn = { explanationTemplate: { name: "题解模板", + goToTheWebsiteToUse: "去网站使用", + problemAddress: "题目地址", + problemDesc: "题目描述", + preKnowledge: "前置知识", + company: "公司", + thinking: "思路", + keyPoints: "关键点", + languageSupport: "语言支持", + complexityAnalysis: "复杂度分析", + complexityDeclare: "令 n 为数组长度。", + timeComplexity: "时间复杂度", + spaceComplexity: "空间复杂度", + howToUse: "如何使用?", + programmingLanguage: "编程语言:1", + commonFormulas: "常用公式(点击可复制):", + noBackup: "没有找到任何备份文件", + restore: "恢复上次编辑内容", + backupTips: "题解每五秒备份一次,如果你不小心刷新了浏览器可以点击下方的恢复按钮还原。由于是覆盖式备份,因此仅会保存最后一次编辑的内容。", + afterUpdateTemplateTips: "后续考虑提供更多题解模板。", + afterUpdateThemeTips:"后续考虑支持更多主题,以及用户自定义主题。" + }, complexityQuickCheck: { name: "复杂度速查", @@ -113,4 +137,5 @@ export const cn = { name: "关于我", }, }; -export default cn; +// export default zh; +module.exports = zh; diff --git a/src/roadmap/roadmap.jsx b/src/roadmap/roadmap.jsx index 28ad061..d8deaa1 100644 --- a/src/roadmap/roadmap.jsx +++ b/src/roadmap/roadmap.jsx @@ -79,7 +79,7 @@ const roadmaps = { ], code: { language: "py", - text: `代码参考:代码模板 - 二分法`, + text: "代码参考:代码模板 - 二分法", }, keys: [ ` diff --git a/src/solutionTemplate/index.jsx b/src/solutionTemplate/index.jsx index 61cb401..5817a9a 100644 --- a/src/solutionTemplate/index.jsx +++ b/src/solutionTemplate/index.jsx @@ -20,6 +20,7 @@ import { debounce, getCloundStorage, } from "../utils.js"; +import { t, lang } from "../locales"; import MarkdownRender from "../components/MarkdownRender"; // import AccessToken from "../components/AccessToken"; @@ -39,6 +40,22 @@ const slogan = ` ![](https://p.ipic.vip/h9nm77.jpg)`; +const sloganEn = ` + +> This solution template is generated by the [LeetCode Solution Template](https://leetcode-pp.github.io/leetcode-cheat/?tab=solution-template) plugin. + +LeetCode friends can [follow me](https://leetcode-cn.com/u/fe-lucifer/) to receive my updates in real-time~ + +That's all for the content of this article. If you have any thoughts or comments, feel free to leave a message, and I will check and respond to them when I have time. For more algorithm techniques, you can visit my LeetCode solution repository: https://github.com/azl397985856/leetcode. It has already gained 40K stars. You can also follow my WeChat official account "LeetCode Plus Plus" to tackle the hard bone of algorithms with clear and straightforward explanations, abundant illustrations, and step-by-step guidance. + +Follow the WeChat official account "LeetCode Plus Plus" and strive to present the solution approach in a clear and concise language, along with numerous illustrations, to help you recognize patterns and efficiently solve problems. + +![](https://p.ipic.vip/h9nm77.jpg)`; + +const getSlogan = () => { + return lang === "en" ? sloganEn : slogan; +}; + function displayLanguage(language) { const m = { python: "Python", @@ -75,52 +92,55 @@ function getTemplate({ isLucifer = false, }) { return ` -## 题目地址(${title}) +## ${t("Locale.explanationTemplate.problemAddress")}(${title}) ${link} -## 题目描述 +## ${t("Locale.explanationTemplate.problemDesc")} ${desc} -## 前置知识 +## ${t("Locale.explanationTemplate.preKnowledge")} - ${pre} -## 公司 +## ${t("Locale.explanationTemplate.company")} - ${company} -## 思路 +## ${t("Locale.explanationTemplate.thinking")} -## 关键点 +## ${t("Locale.explanationTemplate.keyPoints")} - ${keyword} -## 代码 +## Code -- 语言支持:${displayLanguage(language)} +- ${t("Locale.explanationTemplate.languageSupport")}:${displayLanguage( + language + )} ${displayLanguage(language)} Code: -\`\`\`${language.toLocaleLowerCase() === "python3" +\`\`\`${ + language.toLocaleLowerCase() == "python3" ? "python" : language.toLocaleLowerCase() - } + } ${code} \`\`\` -**复杂度分析** +**${t("Locale.explanationTemplate.complexityAnalysis")}** -令 n 为数组长度。 +${t("Locale.explanationTemplate.complexityDeclare")} -- 时间复杂度:$O(${time})$ -- 空间复杂度:$O(${space})$ +- ${t("Locale.explanationTemplate.timeComplexity")}:$O(${time})$ +- ${t("Locale.explanationTemplate.spaceComplexity")}:$O(${space})$ -${isLucifer ? slogan : ""} +${isLucifer ? getSlogan() : ""} `; } function Template({ onChange, template }) { @@ -149,35 +169,36 @@ function Complexities({ value, onChange }) { ); } -const formulas = [ +const getFormulas = (lang) => [ { formula: "$sum_{i=1}^{n}{a_i}$", - name: "求和", + name: lang === "zh" ? "求和" : "sum", logo: require("../imgs/formula/sum.svg"), }, { formula: "$a\\times b$", - name: "乘法", + name: lang === "zh" ? "乘法" : "times", logo: require("../imgs/formula/times.svg"), }, { formula: "$a\\div b$", - name: "除法", + name: lang === "zh" ? "除法" : "div", logo: require("../imgs/formula/div.svg"), }, { formula: "$\\frac{a}{b}$", - name: "分数", + name: lang === "zh" ? "分数" : "frac", + logo: require("../imgs/formula/frac.svg"), }, { formula: "$a\\approx b$", - name: "约等于", + name: lang === "zh" ? "约等于" : "approx", logo: require("../imgs/formula/approx.svg"), }, { formula: "$\\sqrt a$", - name: "根号", + name: lang === "zh" ? "根号" : "sqrt", logo: require("../imgs/formula/sqrt.svg"), }, { @@ -191,7 +212,7 @@ $$ \right. $$ `, - name: "动态规划选择方程", + name: lang === "zh" ? "动态规划选择方程" : "Dynamic programming selection equation", logo: require("../imgs/formula/choice.svg"), }, ]; @@ -309,14 +330,8 @@ export default class SolutionTemplate extends PureComponent { }); } render() { - const { - language, - time, - space, - isLucifer, - template, - isloading, - } = this.state; + const { language, time, space, isLucifer, template, isloading } = + this.state; return ( <> {/* - 如何使用? + {t("Locale.explanationTemplate.howToUse")} {!isInExtension() ? ( <>
    - 编程语言: + {t("Locale.explanationTemplate.programmingLanguage")}: