Skip to content

add nls #171

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
Jan 30, 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
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
## version 2.13.4
## version 2.14.1

- 尝试增加语言本地化

- US站一些报错
## version 2.13.4

- US 站一些报错

## version 2.13.3

- 修改README.md
- 修改 README.md

## version 2.13.2

Expand Down
131 changes: 131 additions & 0 deletions nls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
exports.__esModule = true;
var fse = require("fs-extra");
var result_json = {};
function check_key(object, father) {
var main_join = father.join(".");
if (object["description"]) {
var key = main_join + ".description";
if (result_json[key]) {
console.log("重复", key, object);
}
result_json[key] = object["description"];
}
if (object["title"]) {
var key = main_join + ".title";
if (result_json[key]) {
console.log("重复", key);
}
result_json[key] = object["title"];
}
if (object["name"]) {
var key = main_join + ".name";
if (result_json[key]) {
console.log("重复", key);
}
result_json[key] = object["name"];
}
if (object["label"]) {
var key = main_join + ".label";
if (result_json[key]) {
console.log("重复", key);
}
result_json[key] = object["label"];
}
if (object["enumDescriptions"]) {
var key = main_join + ".enumDescriptions";
if (result_json[key]) {
console.log("重复", key);
}
result_json[key] = object["enumDescriptions"];
}
}
function print_obj(object, father) {
var obj_key = object["command"] || object["id"];
if (obj_key) {
father.push(obj_key);
}
check_key(object, father);
for (var key in object) {
if (Object.prototype.hasOwnProperty.call(object, key)) {
var element = object[key];
father.push(key);
if (Array.isArray(element)) {
print_arr(element, father);
}
else if (typeof element == "object") {
print_obj(element, father);
}
father.pop();
}
}
if (obj_key) {
father.pop();
}
}
function print_arr(object, father) {
for (var i = 0; i < object.length; i++) {
var element = object[i];
if (Array.isArray(element)) {
print_arr(element, father);
}
else if (typeof element == "object") {
print_obj(element, father);
}
}
}
function test() {
return __awaiter(this, void 0, void 0, function () {
var temp_data, ob;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, fse.readFile("./package.json", "utf8")];
case 1:
temp_data = _a.sent();
ob = JSON.parse(temp_data);
print_obj(ob, ["main"]);
return [4 /*yield*/, fse.writeFile("./nls.json", JSON.stringify(result_json))];
case 2:
_a.sent();
return [2 /*return*/];
}
});
});
}
test();
98 changes: 98 additions & 0 deletions nls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"main.description": "LeetCode 官方插件增强, 代码开源, 增加 LeetCode 题目难度分, 给个star吧, 球球了",
"main.name": "vscode-leetcode-problem-rating",
"main.contributes.commands.lcpr.deleteCache.title": "Delete Cache",
"main.contributes.commands.lcpr.toggleLeetCodeCn.title": "Switch Endpoint",
"main.contributes.commands.lcpr.signin.title": "Sign In",
"main.contributes.commands.lcpr.signout.title": "Sign Out",
"main.contributes.commands.lcpr.refreshExplorer.title": "刷新",
"main.contributes.commands.lcpr.pickOne.title": "手气一下",
"main.contributes.commands.lcpr.deleteAllCache.title": "删除题目缓存",
"main.contributes.commands.lcpr.showProblem.title": "做题",
"main.contributes.commands.lcpr.previewProblem.title": "预览题目",
"main.contributes.commands.lcpr.setBricksType0.title": "设置不出现在工地",
"main.contributes.commands.lcpr.setBricksType1.title": "最后一次提交在14天前,出现在工地",
"main.contributes.commands.lcpr.setBricksType2.title": "最后一次提交在7天前,出现在工地",
"main.contributes.commands.lcpr.setBricksType3.title": "最后一次提交在5天前,出现在工地",
"main.contributes.commands.lcpr.setBricksType4.title": "最后一次提交在3天前,出现在工地",
"main.contributes.commands.lcpr.setBricksType5.title": "最后一次提交在2天前,出现在工地",
"main.contributes.commands.lcpr.setBricksType6.title": "最后一次提交在1天前,出现在工地",
"main.contributes.commands.lcpr.setBricksType7.title": "最后一次提交在1天前,出现在工地",
"main.contributes.commands.lcpr.searchProblem.title": "Search Problem",
"main.contributes.commands.lcpr.getHelp.title": "获取题解",
"main.contributes.commands.lcpr.testSolution.title": "Test in LeetCode",
"main.contributes.commands.lcpr.submitSolution.title": "Submit to LeetCode",
"main.contributes.commands.lcpr.addFavorite.title": "Add to Favorite List",
"main.contributes.commands.lcpr.removeFavorite.title": "Remove from Favorite List",
"main.contributes.commands.lcpr.setDefaultLanguage.title": "Switch Default Language",
"main.contributes.commands.lcpr.problems.sort.title": "Sort Problems",
"main.contributes.commands.lcpr.remarkCreateNote.title": "Create Note",
"main.contributes.commands.lcpr.remarkClose.title": "关闭?",
"main.contributes.commands.lcpr.remarkReplyNote.title": "New Note",
"main.contributes.commands.lcpr.remarkEditNote.title": "Edit Note",
"main.contributes.commands.lcpr.remarkDeleteNoteComment.title": "Delete Note",
"main.contributes.commands.lcpr.remarkSaveNote.title": "Save Note",
"main.contributes.commands.lcpr.remarkCancelsaveNote.title": "Cancel Note",
"main.contributes.commands.lcpr.remarkDispose.title": "Remove All Notes",
"main.contributes.commands.lcpr.newBrickGroup.title": "新建一个自定义分类",
"main.contributes.commands.lcpr.addQidToGroup.title": "添加题目到自定义分类",
"main.contributes.commands.lcpr.removeBrickGroup.title": "移除这个自定义分类",
"main.contributes.commands.lcpr.removeQidFromGroup.title": "从分类中移除这个题目",
"main.contributes.commands.lcpr.includeTemplates.title": "插入头文件模板",
"main.contributes.viewsContainers.activitybar.lcpr_bar.title": "LCPR",
"main.contributes.views.lcpr_bar.QuestionExplorer.name": "Problems",
"main.contributes.views.lcpr_bar.BricksExplorer.name": "搬砖工地",
"main.contributes.submenus.lcpr.editorAction.label": "LCPR菜单",
"main.contributes.submenus.lcpr.setBricksType_sub.label": "设置砖头类型",
"main.contributes.submenus.lcpr.setBricksType_sub1.label": "设置砖头类型",
"main.contributes.configuration.title": "leetcode-problem-rating",
"main.contributes.configuration.properties.leetcode-problem-rating.includeTemplates.description": "引入一些默认内容,防止vscode都是波浪红线",
"main.contributes.configuration.properties.leetcode-problem-rating.includeTemplates.items.properties.language.description": "哪种语言",
"main.contributes.configuration.properties.leetcode-problem-rating.includeTemplates.items.properties.template.description": "模板内容",
"main.contributes.configuration.properties.leetcode-problem-rating.hideSolved.description": "Hide solved problems.",
"main.contributes.configuration.properties.leetcode-problem-rating.showLocked.description": "Show locked problems.",
"main.contributes.configuration.properties.leetcode-problem-rating.defaultLanguage.description": "Default language for solving the problems.",
"main.contributes.configuration.properties.leetcode-problem-rating.showDescription.description": "Specify where to show the description.",
"main.contributes.configuration.properties.leetcode-problem-rating.showDescription.enumDescriptions": [
"Show the problem description in a new webview window",
"Show the problem description in the file's comment"
],
"main.contributes.configuration.properties.leetcode-problem-rating.showCommentDescription.description": "[Deprecated] Include problem description in comments.",
"main.contributes.configuration.properties.leetcode-problem-rating.hint.setDefaultLanguage.description": "Show a hint to set the default language.",
"main.contributes.configuration.properties.leetcode-problem-rating.hint.configWebviewMarkdown.description": "Show a hint to change webview appearance through markdown config.",
"main.contributes.configuration.properties.leetcode-problem-rating.hint.commentDescription.description": "Show a hint to enable comment description in solution code file.",
"main.contributes.configuration.properties.leetcode-problem-rating.hint.commandShortcut.description": "Show a hint to configure commands key binding.",
"main.contributes.configuration.properties.leetcode-problem-rating.useVscodeNode.description": "Try the node version of vecode.",
"main.contributes.configuration.properties.leetcode-problem-rating.useWsl.description": "Use the Windows Subsystem for Linux.",
"main.contributes.configuration.properties.leetcode-problem-rating.endpoint.description": "Endpoint of the user account.",
"main.contributes.configuration.properties.leetcode-problem-rating.useEndpointTranslation.description": "Use endpoint's translation (if available)",
"main.contributes.configuration.properties.leetcode-problem-rating.answerDiffColor.description": "答案不同地方上色",
"main.contributes.configuration.properties.leetcode-problem-rating.workspaceFolder.description": "The path of the workspace folder to store the problem files.",
"main.contributes.configuration.properties.leetcode-problem-rating.filePath.description": "The output folder and filename to save the problem files.",
"main.contributes.configuration.properties.leetcode-problem-rating.enableStatusBar.description": "Show the LeetCode status bar or not.",
"main.contributes.configuration.properties.leetcode-problem-rating.editor.shortcuts.description": "Customize the shortcuts in editors.",
"main.contributes.configuration.properties.leetcode-problem-rating.editor.shortcuts.items.enumDescriptions": [
"Submit your answer to LeetCode.",
"Test your answer with customized test cases.",
"Star or unstar the current problem.",
"Show the top voted solution for the current problem.",
"Show the problem description page.",
"Test default case",
"Test all default case"
],
"main.contributes.configuration.properties.leetcode-problem-rating.enableSideMode.description": "Determine whether to group all webview pages into the second editor column when solving problems.",
"main.contributes.configuration.properties.leetcode-problem-rating.nodePath.description": "The Node.js executable path. for example, C:\\Program Files\\nodejs\\node.exe",
"main.contributes.configuration.properties.leetcode-problem-rating.colorizeProblems.description": "Add difficulty badge and colorize problems files in explorer tree.",
"main.contributes.configuration.properties.leetcode-problem-rating.problems.sortStrategy.description": "Sorting strategy for problems list.",
"main.contributes.configuration.properties.leetcode-problem-rating.pickOneByRankRangeMin.description": "Minimum score for a random question(your score + pickOneByRankRangeMin) ",
"main.contributes.configuration.properties.leetcode-problem-rating.pickOneByRankRangeMax.description": "Highest score for a random question(your score + pickOneByRankRangeMax)",
"main.contributes.configuration.properties.leetcode-problem-rating.hideScore.description": "Precinct Score Hidden Questions.",
"main.contributes.configuration.properties.leetcode-problem-rating.hideScore.enumDescriptions": [
"Don't hide",
"Hide questions with scores",
"Hide questions with no scores",
"Hide questions outside the range of scores [pickOneByRankRangeMin, pickOneByRankRangeMax]"
],
"main.contributes.configuration.properties.leetcode-problem-rating.openClearProblemCache.description": "Clear the Problems cache when opening the app to avoid out-of-sync state",
"main.contributes.configuration.properties.leetcode-problem-rating.openClearProblemCacheTime.description": "Open the app to clear the cache interval by default 3600 seconds"
}
88 changes: 88 additions & 0 deletions nls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import * as fse from "fs-extra";

let result_json = {};

function check_key(object, father: Array<any>) {
let main_join = father.join(".");

if (object["description"]) {
let key = main_join + ".description";

if (result_json[key]) {
console.log("重复", key, object);
}

result_json[key] = object["description"];
}
if (object["title"]) {
let key = main_join + ".title";
if (result_json[key]) {
console.log("重复", key);
}
result_json[key] = object["title"];
}
if (object["name"]) {
let key = main_join + ".name";
if (result_json[key]) {
console.log("重复", key);
}
result_json[key] = object["name"];
}
if (object["label"]) {
let key = main_join + ".label";
if (result_json[key]) {
console.log("重复", key);
}
result_json[key] = object["label"];
}
if (object["enumDescriptions"]) {
let key = main_join + ".enumDescriptions";
if (result_json[key]) {
console.log("重复", key);
}
result_json[key] = object["enumDescriptions"];
}
}

function print_obj(object, father) {
let obj_key = object["command"] || object["id"];
if (obj_key) {
father.push(obj_key);
}
check_key(object, father);
for (const key in object) {
if (Object.prototype.hasOwnProperty.call(object, key)) {
const element = object[key];
father.push(key);
if (Array.isArray(element)) {
print_arr(element, father);
} else if (typeof element == "object") {
print_obj(element, father);
}
father.pop();
}
}
if (obj_key) {
father.pop();
}
}
function print_arr(object, father) {
for (let i = 0; i < object.length; i++) {
const element = object[i];

if (Array.isArray(element)) {
print_arr(element, father);
} else if (typeof element == "object") {
print_obj(element, father);
}
}
}

async function test() {
let temp_data = await fse.readFile("./package.json", "utf8");
let ob = JSON.parse(temp_data);
print_obj(ob, ["main"]);
await fse.writeFile("./nls.json", JSON.stringify(result_json));
}

test();
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "vscode-leetcode-problem-rating",
"displayName": "LeetCode",
"description": "LeetCode 官方插件增强, 代码开源, 增加 LeetCode 题目难度分, 给个star吧, 球球了",
"version": "2.13.4",
"description": "%main.description%",
"version": "2.14.1",
"author": "ccagml",
"publisher": "ccagml",
"license": "MIT",
Expand Down
Loading