mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-09-20 02:37:59 +08:00
增加 wangEditor v4 的 国际化语言支持,support eng (#923)
* [il8] 增加html 编辑器的英文模式 * [template] add window.lang * [wangeditor v4] 更新多语音 * [i18n] update eng langure * [i18n] update eng langure * update releaseBook langure --------- Co-authored-by: admin <you@example.com>
This commit is contained in:
@@ -46,6 +46,12 @@ $(function () {
|
||||
console.warn('You could only upload images.');
|
||||
}
|
||||
};
|
||||
editor.config.lang = window.lang;
|
||||
editor.i18next = window.i18next;
|
||||
editor.config.languages['en']['wangEditor']['menus']['title']['保存'] = 'save';
|
||||
editor.config.languages['en']['wangEditor']['menus']['title']['发布'] = 'publish';
|
||||
editor.config.languages['en']['wangEditor']['menus']['title']['附件'] = 'attachment';
|
||||
editor.config.languages['en']['wangEditor']['menus']['title']['history'] = 'history';
|
||||
/*
|
||||
editor.config.menus.splice(0,0,"|");
|
||||
editor.config.menus.splice(0,0,"history");
|
||||
@@ -80,6 +86,57 @@ $(function () {
|
||||
};
|
||||
*/
|
||||
|
||||
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.config.onchange = function (newHtml) {
|
||||
var saveMenu = window.editor.menus.menuList.find((item) => item.key == 'save');
|
||||
// 判断内容是否改变
|
||||
@@ -150,8 +207,8 @@ $(function () {
|
||||
}
|
||||
var version = "";
|
||||
|
||||
if(!node){
|
||||
layer.msg("获取当前文档信息失败");
|
||||
if (!node) {
|
||||
layer.msg(editormdLocales[lang].fetchDocFailed);
|
||||
return;
|
||||
}
|
||||
var doc_id = parseInt(node.id);
|
||||
@@ -191,9 +248,9 @@ $(function () {
|
||||
callback();
|
||||
}
|
||||
}else if(res.errcode === 6005){
|
||||
var confirmIndex = layer.confirm('文档已被其他人修改确定覆盖已存在的文档吗?', {
|
||||
btn: ['确定','取消'] //按钮
|
||||
}, function(){
|
||||
var confirmIndex = layer.confirm(editormdLocales[lang].overrideModified, {
|
||||
btn: [editormdLocales[lang].confirm, editormdLocales[lang].cancel] // 按钮
|
||||
}, function () {
|
||||
layer.close(confirmIndex);
|
||||
saveDocument(true,callback);
|
||||
});
|
||||
@@ -205,6 +262,7 @@ $(function () {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加顶级文档
|
||||
*/
|
||||
@@ -265,7 +323,7 @@ $(function () {
|
||||
"separator_before": false,
|
||||
"separator_after": true,
|
||||
"_disabled": false,
|
||||
"label": "添加文档",
|
||||
"label": window.editormdLocales[window.lang].addDoc,//"添加文档",
|
||||
"icon": "fa fa-plus",
|
||||
"action": function (data) {
|
||||
|
||||
@@ -279,7 +337,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);
|
||||
@@ -291,7 +349,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);
|
||||
@@ -305,7 +363,7 @@ $(function () {
|
||||
window.treeCatalog = $(this).jstree();
|
||||
}).on('select_node.jstree', function (node, selected, event) {
|
||||
if(window.editor.menus.menuList.find((item) => item.key == 'save').$elem.hasClass('selected')) {
|
||||
if(confirm("编辑内容未保存,需要保存吗?")){
|
||||
if (confirm(window.editormdLocales[window.lang].contentUnsaved)) {
|
||||
saveDocument(false,function () {
|
||||
loadDocument(selected);
|
||||
});
|
||||
@@ -321,25 +379,33 @@ $(function () {
|
||||
window.releaseBook = function () {
|
||||
if(Object.prototype.toString.call(window.documentCategory) === '[object Array]' && window.documentCategory.length > 0){
|
||||
if(window.editor.menus.menuList.find((item) => item.key == 'save').$elem.hasClass('selected')) {
|
||||
if(confirm("编辑内容未保存,需要保存吗?")) {
|
||||
if(confirm(editormdLocales[lang].contentUnsaved)) {
|
||||
saveDocument();
|
||||
}
|
||||
}
|
||||
locales = {
|
||||
'zh-CN': {
|
||||
publishToQueue: '发布任务已推送到任务队列,稍后将在后台执行。',
|
||||
},
|
||||
'en': {
|
||||
publishToQueue: 'The publish task has been pushed to the queue</br> and will be executed soon.',
|
||||
}
|
||||
}
|
||||
$.ajax({
|
||||
url : window.releaseURL,
|
||||
data :{"identify" : window.book.identify },
|
||||
type : "post",
|
||||
dataType : "json",
|
||||
success : function (res) {
|
||||
if(res.errcode === 0){
|
||||
layer.msg("发布任务已推送到任务队列,稍后将在后台执行。");
|
||||
}else{
|
||||
url: window.releaseURL,
|
||||
data: {"identify": window.book.identify},
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
if (res.errcode === 0) {
|
||||
layer.msg(locales[lang].publishToQueue);
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg("没有需要发布的文档")
|
||||
layer.msg(editormdLocales[lang].noDocNeedPublish)
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user