Browse Source

fix: 处理流程校验字符串未替换问题

master
tony 3 years ago
parent
commit
ff2ad94368
  1. 34
      ruoyi-ui/src/components/Process/common/customTranslate.js

34
ruoyi-ui/src/components/Process/common/customTranslate.js

@ -1,20 +1,32 @@
import translations from '../lang/zh'
// export default function customTranslate(template, replacements) {
// replacements = replacements || {}
//
// // Translate
// template = translations[template] || template
//
// // Replace
// return template.replace(/{([^}]+)}/g, function(_, key) {
// var str = replacements[key]
// if (
// translations[replacements[key]] !== null &&
// translations[replacements[key]] !== 'undefined'
// ) {
// str = translations[replacements[key]]
// }
// return str || '{' + key + '}'
// })
// }
export default function customTranslate(template, replacements) {
replacements = replacements || {}
replacements = replacements || {};
// Translate
template = translations[template] || template
template = translations[template] || template;
// Replace
return template.replace(/{([^}]+)}/g, function(_, key) {
var str = replacements[key]
if (
translations[replacements[key]] !== null &&
translations[replacements[key]] !== 'undefined'
) {
str = translations[replacements[key]]
}
return str || '{' + key + '}'
})
return replacements[key] || '{' + key + '}';
});
}

Loading…
Cancel
Save