调整bpmn流程设计器组件翻译问题

This commit is contained in:
ZengZhiqiang 2025-05-29 18:10:07 +08:00
parent 00dcbe1684
commit c13f3b86a6
2 changed files with 17 additions and 19 deletions

View File

@ -23,22 +23,20 @@
export default function customTranslate(translations) {
return function (template, replacements) {
replacements = replacements || {}
// Translate
template = translations[template] || template
replacements = replacements || {};
// 将模板和翻译字典的键统一转换为小写进行匹配
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) {
let str = replacements[key]
if (
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 + '}'
})
}
// 如果替换值存在,返回替换值;否则返回原始占位符
return replacements[key] !== undefined ? replacements[key] : `{${key}}`;
});
};
}

View File

@ -45,8 +45,8 @@ export default {
'Service Task': '服务任务',
'Script Task': '脚本任务',
'Call Activity': '调用活动',
'Sub Process (collapsed)': '子流程(折叠的)',
'Sub Process (expanded)': '子流程(展开的)',
'Sub-Process (collapsed)': '子流程(折叠的)',
'Sub-Process (expanded)': '子流程(展开的)',
'Start Event': '开始事件',
StartEvent: '开始事件',
'Intermediate Throw Event': '中间事件',