From ff2ad9436857ebde42c595a9d8f8b8b32a3b9926 Mon Sep 17 00:00:00 2001 From: tony <846249920@qq.com> Date: Thu, 9 Mar 2023 20:08:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=9C=AA=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Process/common/customTranslate.js | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) 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 + '}'; + }); }