diff --git a/ruoyi-ui/src/components/Process/common/customTranslate.js b/ruoyi-ui/src/components/Process/common/customTranslate.js index fa05f9d6..1d58ae2f 100644 --- a/ruoyi-ui/src/components/Process/common/customTranslate.js +++ b/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 + '}'; + }); }