mirror of
https://gitee.com/myxzgzs/boyue-ui-admin-vue3
synced 2025-08-08 16:32:43 +08:00
Merge pull request #154 from cactuer/bpmn-translate-branch
修复BPMN流程设计器组件翻译问题
This commit is contained in:
commit
f6ba881700
@ -23,22 +23,20 @@
|
|||||||
|
|
||||||
export default function customTranslate(translations) {
|
export default function customTranslate(translations) {
|
||||||
return function (template, replacements) {
|
return function (template, replacements) {
|
||||||
replacements = replacements || {}
|
replacements = replacements || {};
|
||||||
// Translate
|
// 将模板和翻译字典的键统一转换为小写进行匹配
|
||||||
template = translations[template] || template
|
const lowerTemplate = template.toLowerCase();
|
||||||
|
const translation = Object.keys(translations).find(key => key.toLowerCase() === lowerTemplate);
|
||||||
|
|
||||||
// Replace
|
// 如果找到匹配的翻译,使用翻译后的模板
|
||||||
|
if (translation) {
|
||||||
|
template = translations[translation];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 替换模板中的占位符
|
||||||
return template.replace(/{([^}]+)}/g, function (_, key) {
|
return template.replace(/{([^}]+)}/g, function (_, key) {
|
||||||
let str = replacements[key]
|
// 如果替换值存在,返回替换值;否则返回原始占位符
|
||||||
if (
|
return replacements[key] !== undefined ? replacements[key] : `{${key}}`;
|
||||||
translations[replacements[key]] !== null &&
|
});
|
||||||
translations[replacements[key]] !== undefined
|
};
|
||||||
) {
|
}
|
||||||
// eslint-disable-next-line no-mixed-spaces-and-tabs
|
|
||||||
str = translations[replacements[key]]
|
|
||||||
// eslint-disable-next-line no-mixed-spaces-and-tabs
|
|
||||||
}
|
|
||||||
return str || '{' + key + '}'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
@ -45,8 +45,8 @@ export default {
|
|||||||
'Service Task': '服务任务',
|
'Service Task': '服务任务',
|
||||||
'Script Task': '脚本任务',
|
'Script Task': '脚本任务',
|
||||||
'Call Activity': '调用活动',
|
'Call Activity': '调用活动',
|
||||||
'Sub Process (collapsed)': '子流程(折叠的)',
|
'Sub-Process (collapsed)': '子流程(折叠的)',
|
||||||
'Sub Process (expanded)': '子流程(展开的)',
|
'Sub-Process (expanded)': '子流程(展开的)',
|
||||||
'Start Event': '开始事件',
|
'Start Event': '开始事件',
|
||||||
StartEvent: '开始事件',
|
StartEvent: '开始事件',
|
||||||
'Intermediate Throw Event': '中间事件',
|
'Intermediate Throw Event': '中间事件',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user