mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-09-18 17:48:00 +08:00
refactor and update i18n, to be continue
This commit is contained in:
@@ -4,12 +4,63 @@ $(function () {
|
||||
css : window.katex.css
|
||||
};
|
||||
|
||||
window.editormdLocales = {
|
||||
'zh-CN': {
|
||||
placeholder: '本编辑器支持 Markdown 编辑,左边编写,右边预览。',
|
||||
contentUnsaved: '编辑内容未保存,需要保存吗?',
|
||||
noDocNeedPublish: '没有需要发布的文档',
|
||||
loadDocFailed: '文档加载失败',
|
||||
fetchDocFailed: '获取当前文档信息失败',
|
||||
cannotAddToEmptyNode: '空节点不能添加内容',
|
||||
overrideModified: '文档已被其他人修改确定覆盖已存在的文档吗?',
|
||||
confirm: '确定',
|
||||
cancel: '取消',
|
||||
contentsNameEmpty: '目录名称不能为空',
|
||||
addDoc: '添加文档',
|
||||
edit: '编辑',
|
||||
delete: '删除',
|
||||
loadFailed: '加载失败请重试',
|
||||
tplNameEmpty: '模板名称不能为空',
|
||||
tplContentEmpty: '模板内容不能为空',
|
||||
saveSucc: '保存成功',
|
||||
serverExcept: '服务器异常',
|
||||
paramName: '参数名称',
|
||||
paramType: '参数类型',
|
||||
example: '示例值',
|
||||
remark: '备注',
|
||||
},
|
||||
'en': {
|
||||
placeholder: 'This editor supports Markdown editing, writing on the left and previewing on the right.',
|
||||
contentUnsaved: 'The edited content is not saved, need to save it?',
|
||||
noDocNeedPublish: 'No Document need to be publish',
|
||||
loadDocFailed: 'Load Document failed',
|
||||
fetchDocFailed: 'Fetch Document info failed',
|
||||
cannotAddToEmptyNode: 'Cannot add content to empty node',
|
||||
overrideModified: 'The document has been modified by someone else, are you sure to overwrite the document?',
|
||||
confirm: 'Confirm',
|
||||
cancel: 'Cancel',
|
||||
contentsNameEmpty: 'Document Name cannot be empty',
|
||||
addDoc: 'Add Document',
|
||||
edit: 'Edit',
|
||||
delete: 'Delete',
|
||||
loadFailed: 'Failed to load, please try again',
|
||||
tplNameEmpty: 'Template name cannot be empty',
|
||||
tplContentEmpty: 'Template content cannot be empty',
|
||||
saveSucc: 'Save success',
|
||||
serverExcept: 'Server Exception',
|
||||
paramName: 'Parameter',
|
||||
paramType: 'Type',
|
||||
example: 'Example',
|
||||
remark: 'Remark',
|
||||
}
|
||||
};
|
||||
|
||||
window.editor = editormd("docEditor", {
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
path: window.editormdLib,
|
||||
toolbar: true,
|
||||
placeholder: "本编辑器支持 Markdown 编辑,左边编写,右边预览。",
|
||||
placeholder: window.editormdLocales[window.lang].placeholder,
|
||||
imageUpload: true,
|
||||
imageFormats: ["jpg", "jpeg", "gif", "png","svg", "JPG", "JPEG", "GIF", "PNG","SVG"],
|
||||
imageUploadURL: window.imageUploadURL,
|
||||
@@ -57,6 +108,7 @@ $(function () {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.isLoad = true;
|
||||
},
|
||||
onchange: function () {
|
||||
@@ -110,7 +162,7 @@ $(function () {
|
||||
} else if (name === "release") {
|
||||
if (Object.prototype.toString.call(window.documentCategory) === '[object Array]' && window.documentCategory.length > 0) {
|
||||
if ($("#markdown-save").hasClass('change')) {
|
||||
var confirm_result = confirm("编辑内容未保存,需要保存吗?");
|
||||
var confirm_result = confirm(editormdLocales[lang].contentUnsaved);
|
||||
if (confirm_result) {
|
||||
saveDocument(false, releaseBook);
|
||||
return;
|
||||
@@ -119,7 +171,7 @@ $(function () {
|
||||
|
||||
releaseBook();
|
||||
} else {
|
||||
layer.msg("没有需要发布的文档")
|
||||
layer.msg(editormdLocales[lang].noDocNeedPublish)
|
||||
}
|
||||
} else if (name === "tasks") {
|
||||
// 插入 GFM 任务列表
|
||||
@@ -175,11 +227,11 @@ $(function () {
|
||||
pushVueLists(res.data.attach);
|
||||
setLastSelectNode($node);
|
||||
} else {
|
||||
layer.msg("文档加载失败");
|
||||
layer.msg(editormdLocales[lang].loadDocFailed);
|
||||
}
|
||||
}).fail(function () {
|
||||
layer.close(index);
|
||||
layer.msg("文档加载失败");
|
||||
layer.msg(editormdLocales[lang].loadDocFailed);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -195,11 +247,11 @@ $(function () {
|
||||
var version = "";
|
||||
|
||||
if (!node) {
|
||||
layer.msg("获取当前文档信息失败");
|
||||
layer.msg(editormdLocales[lang].fetchDocFailed);
|
||||
return;
|
||||
}
|
||||
if (node.a_attr && node.a_attr.disabled) {
|
||||
layer.msg("空节点不能添加内容");
|
||||
layer.msg(editormdLocales[lang].cannotAddToEmptyNode);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -246,8 +298,8 @@ $(function () {
|
||||
}
|
||||
|
||||
} else if(res.errcode === 6005) {
|
||||
var confirmIndex = layer.confirm('文档已被其他人修改确定覆盖已存在的文档吗?', {
|
||||
btn: ['确定', '取消'] // 按钮
|
||||
var confirmIndex = layer.confirm(editormdLocales[lang].overrideModified, {
|
||||
btn: [editormdLocales[lang].confirm, editormdLocales[lang].cancel] // 按钮
|
||||
}, function() {
|
||||
layer.close(confirmIndex);
|
||||
saveDocument(true, callback);
|
||||
@@ -257,7 +309,7 @@ $(function () {
|
||||
}
|
||||
},
|
||||
error : function (XMLHttpRequest, textStatus, errorThrown) {
|
||||
layer.msg("服务器错误:" + errorThrown);
|
||||
layer.msg(window.editormdLocales[window.lang].serverExcept + errorThrown);
|
||||
},
|
||||
complete :function () {
|
||||
layer.close(index);
|
||||
@@ -287,7 +339,7 @@ $(function () {
|
||||
beforeSubmit: function () {
|
||||
var doc_name = $.trim($("#documentName").val());
|
||||
if (doc_name === "") {
|
||||
return showError("目录名称不能为空", "#add-error-message")
|
||||
return showError(editormdLocales[lang].contentsNameEmpty, "#add-error-message")
|
||||
}
|
||||
$("#btnSaveDocument").button("loading");
|
||||
return true;
|
||||
@@ -347,7 +399,7 @@ $(function () {
|
||||
"separator_before": false,
|
||||
"separator_after": true,
|
||||
"_disabled": false,
|
||||
"label": "添加文档",
|
||||
"label": window.editormdLocales[window.lang].addDoc,//"添加文档",
|
||||
"icon": "fa fa-plus",
|
||||
"action": function (data) {
|
||||
var inst = $.jstree.reference(data.reference),
|
||||
@@ -360,7 +412,7 @@ $(function () {
|
||||
"separator_before": false,
|
||||
"separator_after": true,
|
||||
"_disabled": false,
|
||||
"label": "编辑",
|
||||
"label": window.editormdLocales[window.lang].edit,
|
||||
"icon": "fa fa-edit",
|
||||
"action": function (data) {
|
||||
var inst = $.jstree.reference(data.reference);
|
||||
@@ -372,7 +424,7 @@ $(function () {
|
||||
"separator_before": false,
|
||||
"separator_after": true,
|
||||
"_disabled": false,
|
||||
"label": "删除",
|
||||
"label": window.editormdLocales[window.lang].delete,
|
||||
"icon": "fa fa-trash-o",
|
||||
"action": function (data) {
|
||||
var inst = $.jstree.reference(data.reference);
|
||||
@@ -390,7 +442,7 @@ $(function () {
|
||||
}).on('select_node.jstree', function (node, selected) {
|
||||
|
||||
if ($("#markdown-save").hasClass('change')) {
|
||||
if (confirm("编辑内容未保存,需要保存吗?")) {
|
||||
if (confirm(window.editormdLocales[window.lang].contentUnsaved)) {
|
||||
saveDocument(false, function () {
|
||||
loadDocument(selected);
|
||||
});
|
||||
@@ -446,7 +498,7 @@ $(function () {
|
||||
$("#displayCustomsTemplateList").html($res);
|
||||
},
|
||||
error : function () {
|
||||
layer.msg("加载失败请重试");
|
||||
layer.msg(window.editormdLocales[window.lang].loadFailed);
|
||||
},
|
||||
complete : function () {
|
||||
layer.close(index);
|
||||
@@ -464,11 +516,11 @@ $(function () {
|
||||
beforeSubmit: function () {
|
||||
var doc_name = $.trim($("#templateName").val());
|
||||
if (doc_name === "") {
|
||||
return showError("模板名称不能为空", "#saveTemplateForm .show-error-message");
|
||||
return showError(window.editormdLocales[window.lang].tplNameEmpty, "#saveTemplateForm .show-error-message");
|
||||
}
|
||||
var content = $("#saveTemplateForm").find("input[name='content']").val();
|
||||
if (content === ""){
|
||||
return showError("模板内容不能为空", "#saveTemplateForm .show-error-message");
|
||||
return showError(window.editormdLocales[window.lang].tplContentEmpty, "#saveTemplateForm .show-error-message");
|
||||
}
|
||||
|
||||
$("#btnSaveTemplate").button("loading");
|
||||
@@ -478,7 +530,7 @@ $(function () {
|
||||
success: function ($res) {
|
||||
if($res.errcode === 0){
|
||||
$("#saveTemplateModal").modal("hide");
|
||||
layer.msg("保存成功");
|
||||
layer.msg(window.editormdLocales[window.lang].saveSucc);
|
||||
}else{
|
||||
return showError($res.message, "#saveTemplateForm .show-error-message");
|
||||
}
|
||||
@@ -521,7 +573,7 @@ $(function () {
|
||||
resetEditorChanged(true);
|
||||
$("#displayCustomsTemplateModal").modal("hide");
|
||||
},error : function () {
|
||||
layer.msg("服务器异常");
|
||||
layer.msg(window.editormdLocales[window.lang].serverExcept);
|
||||
}
|
||||
});
|
||||
}).on("click",".btn-delete",function () {
|
||||
@@ -541,7 +593,7 @@ $(function () {
|
||||
$then.parents("tr").empty().remove();
|
||||
}
|
||||
},error : function () {
|
||||
layer.msg("服务器异常");
|
||||
layer.msg(window.editormdLocales[window.lang].serverExcept);
|
||||
},
|
||||
complete: function () {
|
||||
$then.button("reset");
|
||||
@@ -555,7 +607,11 @@ $(function () {
|
||||
try {
|
||||
var jsonObj = $.parseJSON(content);
|
||||
var data = foreachJson(jsonObj,"");
|
||||
var table = "| 参数名称 | 参数类型 | 示例值 | 备注 |\n| ------------ | ------------ | ------------ | ------------ |\n";
|
||||
var table = "| " + window.editormdLocales[window.lang].paramName
|
||||
+ " | " + window.editormdLocales[window.lang].paramType
|
||||
+ " | " + window.editormdLocales[window.lang].example
|
||||
+ " | " + window.editormdLocales[window.lang].remark
|
||||
+ " |\n| ------------ | ------------ | ------------ | ------------ |\n";
|
||||
$.each(data,function (i,item) {
|
||||
table += "|" + item.key + "|" + item.type + "|" + item.value +"| |\n";
|
||||
});
|
||||
|
Reference in New Issue
Block a user