Demo:完善多语言

This commit is contained in:
wanglin2 2023-10-16 18:43:07 +08:00
parent 7bc666be36
commit 4dedaaea3b
11 changed files with 182 additions and 81 deletions

View File

@ -114,7 +114,8 @@ export default {
'If the download is not triggered, check whether it is blocked by the browser',
paddingX: 'Padding x',
paddingY: 'Padding y',
useMultiPageExport: 'Export multi page'
useMultiPageExport: 'Export multi page',
defaultFileName: 'Mind map'
},
fullscreen: {
fullscreenShow: 'Full screen show',
@ -123,7 +124,13 @@ export default {
import: {
title: 'Import',
selectFile: 'Select file',
supportFile: 'Support .smm、.json、.xmind、.xlsx、.md file'
supportFile: 'Support .smm、.json、.xmind、.xlsx、.md file',
enableFileTip: 'Please select .smm、.json、.xmind、.xlsx、.md file',
maxFileNum: 'At most one file can be selected',
notSelectTip: 'Please select the file to import',
fileContentError: 'The file content is incorrect',
importSuccess: 'Import success',
fileParsingFailed: 'File parsing failed'
},
navigatorToolbar: {
openMiniMap: 'Open mini map',
@ -192,7 +199,15 @@ export default {
vertical: 'Vertical'
},
theme: {
title: 'Theme'
title: 'Theme',
classics: 'Classics',
dark: 'Darkness',
simple: 'Simple',
coverTip:
'You have currently customized the basic style, do you want to overwrite it?',
tip: 'Tip',
cover: 'Cover',
reserve: 'Reserve'
},
toolbar: {
undo: 'Undo',
@ -219,12 +234,27 @@ export default {
associativeLine: 'Associative line',
painter: 'Painter',
formula: 'Formula',
more: 'More'
more: 'More',
selectFileTip: 'Please select a file',
notSupportTip:
'Your browser or network protocol does not support this feature',
tip: 'Tip',
editingLocalFileTipFront: 'Currently editing your local【',
editingLocalFileTipEnd: '】file',
fileContentError: 'File content error',
fileOpenFailed: 'File open failed',
defaultFileName: 'Mind map',
creatingTip: 'Creating file'
},
edit: {
newFeatureNoticeTitle: 'New feature reminder',
newFeatureNoticeMessage:
'This update supports node rich text editing, But there are some defects, The most important impact is that the time to export the image is proportional to the number of nodes, Therefore, if you are more dependent on export requirements, you can use【Base style】-【Other config】-【Enable node rich text editing】Set to turn off rich text editing mode.'
'This update supports node rich text editing, But there are some defects, The most important impact is that the time to export the image is proportional to the number of nodes, Therefore, if you are more dependent on export requirements, you can use【Base style】-【Other config】-【Enable node rich text editing】Set to turn off rich text editing mode.',
root: 'Root node',
splitByWrap: 'Is automatically split nodes based on line breaks?',
tip: 'Tip',
yes: 'Yes',
no: 'No'
},
mouseAction: {
tip1:
@ -248,6 +278,21 @@ export default {
title: 'Formula',
placeholder: 'Please enter LaText syntax',
confirm: 'Confirm',
common: 'Common formulas'
common: 'Common formulas',
tip: 'Inserting formulas is not supported in non rich text mode'
},
richTextToolbar: {
bold: 'Bold',
italic: 'Italic',
underline: 'Underline',
strike: 'Strike',
fontFamily: 'Font family',
fontSize: 'Font size',
color: 'Color',
backgroundColor: 'Background color',
removeFormat: 'Clear Style'
},
other: {
loading: 'Loading, please wait...'
}
}

View File

@ -112,7 +112,8 @@ export default {
notifyMessage: '如果没有触发下载,请检查是否被浏览器拦截了',
paddingX: '水平内边距',
paddingY: '垂直内边距',
useMultiPageExport: '是否多页导出'
useMultiPageExport: '是否多页导出',
defaultFileName: '思维导图'
},
fullscreen: {
fullscreenShow: '全屏查看',
@ -121,7 +122,13 @@ export default {
import: {
title: '导入',
selectFile: '选取文件',
supportFile: '支持.smm、.json、.xmind、.xlsx、.md文件'
supportFile: '支持.smm、.json、.xmind、.xlsx、.md文件',
enableFileTip: '请选择.smm、.json、.xmind、.xlsx、.md文件',
maxFileNum: '最多只能选择一个文件',
notSelectTip: '请选择要导入的文件',
fileContentError: '文件内容有误',
importSuccess: '导入成功',
fileParsingFailed: '文件解析失败'
},
navigatorToolbar: {
openMiniMap: '开启小地图',
@ -190,7 +197,14 @@ export default {
vertical: '垂直'
},
theme: {
title: '主题'
title: '主题',
classics: '经典',
dark: '深色',
simple: '朴素',
coverTip: '你当前自定义过基础样式,是否覆盖?',
tip: '提示',
cover: '覆盖',
reserve: '保留'
},
toolbar: {
undo: '回退',
@ -217,12 +231,26 @@ export default {
associativeLine: '关联线',
painter: '格式刷',
formula: '公式',
more: '更多'
more: '更多',
selectFileTip: '请选择文件',
notSupportTip: '你的浏览器或网络协议不支持该功能',
tip: '提示',
editingLocalFileTipFront: '当前正在编辑你本机的【',
editingLocalFileTipEnd: '】文件',
fileContentError: '文件内容有误',
fileOpenFailed: '文件打开失败',
defaultFileName: '思维导图',
creatingTip: '正在创建文件'
},
edit: {
newFeatureNoticeTitle: '新特性提醒',
newFeatureNoticeMessage:
'本次更新支持了节点富文本编辑,但是存在一定缺陷,最主要的影响是导出为图片的时间和节点数量成正比,所以对导出需求比较依赖的话可以通过【基础样式】-【其他配置】-【是否开启节点富文本编辑】设置关掉富文本编辑模式。'
'本次更新支持了节点富文本编辑,但是存在一定缺陷,最主要的影响是导出为图片的时间和节点数量成正比,所以对导出需求比较依赖的话可以通过【基础样式】-【其他配置】-【是否开启节点富文本编辑】设置关掉富文本编辑模式。',
root: '根节点',
splitByWrap: '是否按换行自动分割节点?',
tip: '提示',
yes: '是',
no: '否'
},
mouseAction: {
tip1: '当前:左键拖动画布,右键框选节点',
@ -244,6 +272,21 @@ export default {
title: '公式',
placeholder: '请输入 LaText 语法',
confirm: '完成',
common: '常用公式'
common: '常用公式',
tip: '非富文本模式下不支持插入公式'
},
richTextToolbar: {
bold: '加粗',
italic: '斜体',
underline: '下划线',
strike: '删除线',
fontFamily: '字体',
fontSize: '字号',
color: '字体颜色',
backgroundColor: '背景颜色',
removeFormat: '清除样式'
},
other: {
loading: '正在加载,请稍后...'
}
}

View File

@ -43,7 +43,7 @@ export default {
this.initLocalConfig()
const loading = this.$loading({
lock: true,
text: '正在加载,请稍后...'
text: this.$t('other.loading')
})
await this.getUserMindMapData()
this.show = true

View File

@ -11,7 +11,7 @@
@click="exec('INSERT_NODE', insertNodeBtnDisabled)"
:class="{ disabled: insertNodeBtnDisabled }"
>
{{ $t('contextmenu.insertSiblingNode') }}
<span class="name">{{ $t('contextmenu.insertSiblingNode') }}</span>
<span class="desc">Enter</span>
</div>
<div
@ -19,7 +19,7 @@
@click="exec('INSERT_CHILD_NODE')"
:class="{ disabled: isGeneralization }"
>
{{ $t('contextmenu.insertChildNode') }}
<span class="name">{{ $t('contextmenu.insertChildNode') }}</span>
<span class="desc">Tab</span>
</div>
<div
@ -27,7 +27,7 @@
@click="exec('INSERT_PARENT_NODE')"
:class="{ disabled: insertNodeBtnDisabled }"
>
{{ $t('contextmenu.insertParentNode') }}
<span class="name">{{ $t('contextmenu.insertParentNode') }}</span>
<span class="desc">Shift + Tab</span>
</div>
<div
@ -35,7 +35,7 @@
@click="exec('ADD_GENERALIZATION')"
:class="{ disabled: insertNodeBtnDisabled }"
>
{{ $t('contextmenu.insertSummary') }}
<span class="name">{{ $t('contextmenu.insertSummary') }}</span>
<span class="desc">Ctrl + G</span>
</div>
<div
@ -43,7 +43,7 @@
@click="exec('UP_NODE')"
:class="{ disabled: upNodeBtnDisabled }"
>
{{ $t('contextmenu.moveUpNode') }}
<span class="name">{{ $t('contextmenu.moveUpNode') }}</span>
<span class="desc">Ctrl + </span>
</div>
<div
@ -51,15 +51,15 @@
@click="exec('DOWN_NODE')"
:class="{ disabled: downNodeBtnDisabled }"
>
{{ $t('contextmenu.moveDownNode') }}
<span class="name">{{ $t('contextmenu.moveDownNode') }}</span>
<span class="desc">Ctrl + </span>
</div>
<div class="item danger" @click="exec('REMOVE_NODE')">
{{ $t('contextmenu.deleteNode') }}
<span class="name">{{ $t('contextmenu.deleteNode') }}</span>
<span class="desc">Delete</span>
</div>
<div class="item danger" @click="exec('REMOVE_CURRENT_NODE')">
{{ $t('contextmenu.deleteCurrentNode') }}
<span class="name">{{ $t('contextmenu.deleteCurrentNode') }}</span>
<span class="desc">Shift + Backspace</span>
</div>
<div
@ -67,7 +67,7 @@
@click="exec('COPY_NODE')"
:class="{ disabled: isGeneralization }"
>
{{ $t('contextmenu.copyNode') }}
<span class="name">{{ $t('contextmenu.copyNode') }}</span>
<span class="desc">Ctrl + C</span>
</div>
<div
@ -75,33 +75,33 @@
@click="exec('CUT_NODE')"
:class="{ disabled: isGeneralization }"
>
{{ $t('contextmenu.cutNode') }}
<span class="name">{{ $t('contextmenu.cutNode') }}</span>
<span class="desc">Ctrl + X</span>
</div>
<div class="item" @click="exec('PASTE_NODE')">
{{ $t('contextmenu.pasteNode') }}
<span class="name">{{ $t('contextmenu.pasteNode') }}</span>
<span class="desc">Ctrl + V</span>
</div>
<div class="item" @click="exec('REMOVE_HYPERLINK')" v-if="hasHyperlink">
{{ $t('contextmenu.removeHyperlink') }}
<span class="name">{{ $t('contextmenu.removeHyperlink') }}</span>
</div>
<div class="item" @click="exec('REMOVE_NOTE')" v-if="hasNote">
{{ $t('contextmenu.removeNote') }}
<span class="name">{{ $t('contextmenu.removeNote') }}</span>
</div>
</template>
<template v-if="type === 'svg'">
<div class="item" @click="exec('RETURN_CENTER')">
{{ $t('contextmenu.backCenter') }}
<span class="name">{{ $t('contextmenu.backCenter') }}</span>
<span class="desc">Ctrl + Enter</span>
</div>
<div class="item" @click="exec('EXPAND_ALL')">
{{ $t('contextmenu.expandAll') }}
<span class="name">{{ $t('contextmenu.expandAll') }}</span>
</div>
<div class="item" @click="exec('UNEXPAND_ALL')">
{{ $t('contextmenu.unExpandAll') }}
<span class="name">{{ $t('contextmenu.unExpandAll') }}</span>
</div>
<div class="item">
{{ $t('contextmenu.expandTo') }}
<span class="name">{{ $t('contextmenu.expandTo') }}</span>
<div class="subItems listBox" :class="{ isDark: isDark }">
<div
class="item"
@ -114,15 +114,15 @@
</div>
</div>
<div class="item" @click="exec('RESET_LAYOUT')">
{{ $t('contextmenu.arrangeLayout') }}
<span class="name">{{ $t('contextmenu.arrangeLayout') }}</span>
<span class="desc">Ctrl + L</span>
</div>
<div class="item" @click="exec('FIT_CANVAS')">
{{ $t('contextmenu.fitCanvas') }}
<span class="name">{{ $t('contextmenu.fitCanvas') }}</span>
<span class="desc">Ctrl + i</span>
</div>
<div class="item" @click="exec('TOGGLE_ZEN_MODE')">
{{ $t('contextmenu.zenMode') }}
<span class="name">{{ $t('contextmenu.zenMode') }}</span>
{{ isZenMode ? '√' : '' }}
</div>
</template>
@ -403,8 +403,17 @@ export default {
}
}
.name {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.desc {
color: #999;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.subItems {

View File

@ -275,7 +275,7 @@ export default {
if (hasFileURL) {
root = {
data: {
text: '根节点'
text: this.$t('edit.root')
},
children: []
}
@ -308,9 +308,9 @@ export default {
enableAutoEnterTextEditWhenKeydown: true,
customHandleClipboardText: handleClipboardText,
handleIsSplitByWrapOnPasteCreateNewNode: () => {
return this.$confirm('是否按换行自动分割节点?', '提示', {
confirmButtonText: '是',
cancelButtonText: '否',
return this.$confirm(this.$t('edit.splitByWrap'), this.$t('edit.tip'), {
confirmButtonText: this.$t('edit.yes'),
cancelButtonText: this.$t('edit.no'),
type: 'warning'
})
}

View File

@ -101,7 +101,7 @@ export default {
return {
dialogVisible: false,
exportType: 'smm',
fileName: '思维导图',
fileName: this.$t('export.defaultFileName'),
widthConfig: true,
isTransparent: false,
loading: false,

View File

@ -89,14 +89,17 @@ export default {
handleNodeActive(...args) {
this.activeNodes = [...args[1]]
if (this.activeNodes.length <= 0 && this.activeSidebar === 'formulaSidebar') {
if (
this.activeNodes.length <= 0 &&
this.activeSidebar === 'formulaSidebar'
) {
this.setActiveSidebar(null)
}
},
confirm() {
if (!this.localConfig.openNodeRichText) {
return this.$message.warning('非富文本模式下不支持插入公式')
return this.$message.warning(this.$t('formulaSidebar.tip'))
}
let str = this.formulaText.trim()
if (!str) return

View File

@ -107,7 +107,7 @@ export default {
onChange(file) {
let reg = /\.(smm|xmind|json|xlsx|md)$/
if (!reg.test(file.name)) {
this.$message.error('请选择.smm、.json、.xmind、.xlsx、.md文件')
this.$message.error(this.$t('import.enableFileTip'))
this.fileList = []
} else {
this.fileList.push(file)
@ -120,7 +120,7 @@ export default {
* @Desc: 数量超出限制
*/
onExceed() {
this.$message.error('最多只能选择一个文件')
this.$message.error(this.$t('import.maxFileNum'))
},
/**
@ -139,7 +139,7 @@ export default {
*/
confirm() {
if (this.fileList.length <= 0) {
return this.$message.error('请选择要导入的文件')
return this.$message.error(this.$t('import.notSelectTip'))
}
this.$store.commit('setIsHandleLocalFile', false)
let file = this.fileList[0]
@ -151,7 +151,7 @@ export default {
this.handleExcel(file)
} else if (/\.md$/.test(file.name)) {
this.handleMd(file)
}
}
this.cancel()
},
@ -167,13 +167,13 @@ export default {
try {
let data = JSON.parse(evt.target.result)
if (typeof data !== 'object') {
throw new Error('文件内容有误')
throw new Error(this.$t('import.fileContentError'))
}
this.$bus.$emit('setData', data)
this.$message.success('导入成功')
this.$message.success(this.$t('import.importSuccess'))
} catch (error) {
console.log(error)
this.$message.error('文件解析失败')
this.$message.error(this.$t('import.fileParsingFailed'))
}
}
},
@ -187,10 +187,10 @@ export default {
try {
let data = await xmind.parseXmindFile(file.raw)
this.$bus.$emit('setData', data)
this.$message.success('导入成功')
this.$message.success(this.$t('import.importSuccess'))
} catch (error) {
console.log(error)
this.$message.error('文件解析失败')
this.$message.error(this.$t('import.fileParsingFailed'))
}
},
@ -254,10 +254,10 @@ export default {
}
}
this.$bus.$emit('setData', layers[0][0])
this.$message.success('导入成功')
this.$message.success(this.$t('import.importSuccess'))
} catch (error) {
console.log(error)
this.$message.error('文件解析失败')
this.$message.error(this.$t('import.fileParsingFailed'))
}
},
@ -269,10 +269,10 @@ export default {
try {
let data = await markdown.transformMarkdownTo(evt.target.result)
this.$bus.$emit('setData', data)
this.$message.success('导入成功')
this.$message.success(this.$t('import.importSuccess'))
} catch (error) {
console.log(error)
this.$message.error('文件解析失败')
this.$message.error(this.$t('import.fileParsingFailed'))
}
}
}

View File

@ -7,13 +7,13 @@
@click.stop.passive
v-show="showRichTextToolbar"
>
<el-tooltip content="加粗" placement="top">
<el-tooltip :content="$t('richTextToolbar.bold')" placement="top">
<div class="btn" :class="{ active: formatInfo.bold }" @click="toggleBold">
<span class="icon iconfont iconzitijiacu"></span>
</div>
</el-tooltip>
<el-tooltip content="斜体" placement="top">
<el-tooltip :content="$t('richTextToolbar.italic')" placement="top">
<div
class="btn"
:class="{ active: formatInfo.italic }"
@ -23,7 +23,7 @@
</div>
</el-tooltip>
<el-tooltip content="下划线" placement="top">
<el-tooltip :content="$t('richTextToolbar.underline')" placement="top">
<div
class="btn"
:class="{ active: formatInfo.underline }"
@ -33,7 +33,7 @@
</div>
</el-tooltip>
<el-tooltip content="删除线" placement="top">
<el-tooltip :content="$t('richTextToolbar.strike')" placement="top">
<div
class="btn"
:class="{ active: formatInfo.strike }"
@ -43,7 +43,7 @@
</div>
</el-tooltip>
<el-tooltip content="字体" placement="top">
<el-tooltip :content="$t('richTextToolbar.fontFamily')" placement="top">
<el-popover placement="bottom" trigger="hover">
<div class="fontOptionsList" :class="{ isDark: isDark }">
<div
@ -63,7 +63,7 @@
</el-popover>
</el-tooltip>
<el-tooltip content="字号" placement="top">
<el-tooltip :content="$t('richTextToolbar.fontSize')" placement="top">
<el-popover placement="bottom" trigger="hover">
<div class="fontOptionsList" :class="{ isDark: isDark }">
<div
@ -83,7 +83,7 @@
</el-popover>
</el-tooltip>
<el-tooltip content="字体颜色" placement="top">
<el-tooltip :content="$t('richTextToolbar.color')" placement="top">
<el-popover placement="bottom" trigger="hover">
<Color :color="fontColor" @change="changeFontColor"></Color>
<div class="btn" slot="reference" :style="{ color: formatInfo.color }">
@ -92,7 +92,10 @@
</el-popover>
</el-tooltip>
<el-tooltip content="背景颜色" placement="top">
<el-tooltip
:content="$t('richTextToolbar.backgroundColor')"
placement="top"
>
<el-popover placement="bottom" trigger="hover">
<Color
:color="fontBackgroundColor"
@ -104,7 +107,7 @@
</el-popover>
</el-tooltip>
<el-tooltip content="清除样式" placement="top">
<el-tooltip :content="$t('richTextToolbar.removeFormat')" placement="top">
<div class="btn" @click="removeFormat">
<span class="icon iconfont iconqingchu"></span>
</div>

View File

@ -122,17 +122,17 @@ export default {
})
this.groupList = [
{
name: '经典',
name: this.$t('theme.classics'),
list: classicsList
},
{
name: '深色',
name: this.$t('theme.dark'),
list: this.themeList.filter(item => {
return item.dark
})
},
{
name: '朴素',
name: this.$t('theme.simple'),
list: baiduList
}
]
@ -146,9 +146,9 @@ export default {
const customThemeConfig = this.mindMap.getCustomThemeConfig()
const hasCustomThemeConfig = Object.keys(customThemeConfig).length > 0
if (hasCustomThemeConfig) {
this.$confirm('你当前自定义过基础样式,是否覆盖?', '提示', {
confirmButtonText: '覆盖',
cancelButtonText: '保留',
this.$confirm(this.$t('theme.coverTip'), this.$t('theme.tip'), {
confirmButtonText: this.$t('theme.cover'),
cancelButtonText: this.$t('theme.reserve'),
type: 'warning'
})
.then(() => {

View File

@ -195,7 +195,7 @@ export default {
}
fileHandle = _fileHandle
if (fileHandle.kind === 'directory') {
this.$message.warning('请选择文件')
this.$message.warning(this.$t('toolbar.selectFileTip'))
return
}
this.readFile()
@ -204,9 +204,7 @@ export default {
if (error.toString().includes('aborted')) {
return
}
this.$message.warning(
'你的浏览器可能不支持建议使用最新版本的Chrome浏览器'
)
this.$message.warning(this.$t('toolbar.notSupportTip'))
}
},
@ -219,8 +217,10 @@ export default {
this.setData(fileReader.result)
Notification.closeAll()
Notification({
title: '提示',
message: `当前正在编辑你本机的【${file.name}】文件`,
title: this.$t('toolbar.tip'),
message: `${this.$t('toolbar.editingLocalFileTipFront')}${
file.name
}${this.$t('toolbar.editingLocalFileTipEnd')}`,
duration: 0,
showClose: true
})
@ -233,7 +233,7 @@ export default {
try {
let data = JSON.parse(str)
if (typeof data !== 'object') {
throw new Error('文件内容有误')
throw new Error(this.$t('toolbar.fileContentError'))
}
if (data.root) {
this.isFullDataFile = true
@ -247,7 +247,7 @@ export default {
this.$bus.$emit('setData', data)
} catch (error) {
console.log(error)
this.$message.error('文件打开失败')
this.$message.error(this.$t('toolbar.fileOpenFailed'))
}
},
@ -286,14 +286,14 @@ export default {
accept: { 'application/json': ['.smm'] }
}
],
suggestedName: '思维导图'
suggestedName: this.$t('toolbar.defaultFileName')
})
if (!_fileHandle) {
return
}
const loading = this.$loading({
lock: true,
text: '正在创建文件',
text: this.$t('toolbar.creatingTip'),
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
@ -308,9 +308,7 @@ export default {
if (error.toString().includes('aborted')) {
return
}
this.$message.warning(
'你的浏览器可能不支持建议使用最新版本的Chrome浏览器'
)
this.$message.warning(this.$t('toolbar.notSupportTip'))
}
}
}