bpmn-js画流程图 (二)框架英文汉化实现
工具栏,控件,和面板的提示都可以汉化成中文。
bpmn官网多语言示例:https://github.com/bpmn-io/bpmn-js-examples/tree/master/i18n
将例子里的customTranslate文件夹拷贝到项目里,然后在初始化的时候加上如下代码
首先引入汉化文件
import customTranslate from './customTranslate/customTranslate';
然后初始化
var customTranslateModule = {
translate: [ 'value', customTranslate ]
};
const canvas = this.$refs.canvas;
this.bpmnModeler = new BpmnModeler({
container: canvas,
additionalModules:[
customTranslateModule
]
})
修改customTranslate文件夹里的汉化映射 translations.js
/** * This is a sample file that should be replaced with the actual translation. * * Checkout https://github.com/bpmn-io/bpmn-js-i18n for a list of available * translations and labels to translate. */ export default { //工具菜单提示ContextPadProvider.js,PaletteProvider.js 'Create EndEvent':'创建结束节点', 'Append EndEvent':'添加结束节点', 'Append Gateway':'添加分支', //节点功能按键 'Exclusive Gateway': 'Exklusives Gateway', 'Parallel Gateway': 'Paralleles Gateway', 'Inclusive Gateway': 'Inklusives Gateway', 'Complex Gateway': 'Komplexes Gateway', 'Event based Gateway': 'Ereignis-basiertes Gateway', 'Message Start Event': '消息启动事件', 'Timer Start Event': '定时启动事件', 'Conditional Start Event': '条件启动事件', 'Signal Start Event': '信号启动事件', 'Error Start Event': '错误启动事件', 'Escalation Start Event': '升级启动事件', 'Compensation Start Event': '补偿启动事件', 'Message Start Event (non-interrupting)': '消息启动事件 (非中断)', 'Timer Start Event (non-interrupting)': '定时启动事件 (非中断)', 'Conditional Start Event (non-interrupting)': '条件启动事件 (非中断)', 'Signal Start Event (non-interrupting)': '信号启动事件 (非中断)', 'Escalation Start Event (non-interrupting)': '升级启动事件 (非中断)', //---------属性面板-------- 'General':'通用', 'Details':'详情', 'Documentation':'文档', 'Version Tag':'版本标签', 'Category Value':'类别值', 'Process Id':'进程 Id', 'Process Name':'进程 Name', 'Link Name':'链接名称', 'Element Documentation':'元素文档', 'Process Documentation':'进程文档', 'Executable':'可执行', 'Task Priority':'任务优先级', };