// 引入流程图及汉化方案
import Modeler from 'bpmn-js/lib/Modeler'
// 引入节点属性面板
import propertiesPanelModule from 'bpmn-js-properties-panel'
import propertiesProviderModule from 'bpmn-js-properties-panel/lib/provider/camunda'
import camundaModdleDescriptor from 'camunda-bpmn-moddle/resources/camunda'
//汉化方案
import customTranslate from './dist/customTranslate';//汉化处理函数
// 翻译英文,汉化
var customTranslateModule = {
translate: ['value', customTranslate]
};
// 生成实例
this.modeler = new Modeler({
container: '#workFlowCanvas',
propertiesPanel: {
parent: '#js-properties-panel'
},
additionalModules: [
customTranslateModule,//汉化包
propertiesPanelModule,//左侧任务栏
propertiesProviderModule//右侧属性栏(基本属性)
],
moddleExtensions: {
camunda: camundaModdleDescriptor//属性栏里面的详情等属性(高级属性)
}
})
//customTranslate.js文件内容
//下面为汉化包引入
// import translations from './translations1';
import translations from './translations';
// import translations from './translationSultan';
export default function customTranslate(template, replacements) {
replacements = replacements || {};
// Translate
template = translations[template] || template;
// Replace
return template.replace(/{([^}]+)}/g, function(_, key) {
return replacements[key] || '{' + key + '}';
});
}
标签:流程图,customTranslate,bpmn,translations,js,template,import
From: https://www.cnblogs.com/Sultan-ST/p/16865852.html