diff --git a/app/Module/Doo.php b/app/Module/Doo.php index 73ffdff5a..52125f864 100644 --- a/app/Module/Doo.php +++ b/app/Module/Doo.php @@ -269,32 +269,12 @@ class Doo /** * 翻译 * @param $text + * @param string $type * @return string */ - public static function translate($text): string + public static function translate($text, string $type = ""): string { - // 存在版本号 且 低于0.38.28时 使用原文 - $version = Base::headerOrInput('version'); - if ($version && !Base::judgeClientVersion('0.38.28', $version)) { - return $text; - } - - if (is_string($text)) { - // 等于success、error、warning、info、(为空)时不处理 - if (in_array($text, ['success', 'error', 'warning', 'info', ''])) { - return $text; - } - // 以__L(开头,)__结尾的不处理 - if (str_starts_with($text, "__L(") && str_ends_with($text, ")__")) { - return $text; - } - $text = "__L(" . $text . ")__"; - } elseif (is_array($text)) { - foreach ($text as $key => $val) { - $text[$key] = self::translate($val); - } - } - return $text; + return self::string(self::doo()->translate($text, $type)); } /** diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 30d0abd74..f5e9d835e 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -229,25 +229,6 @@ $A.bindScreenshotKey = (data) => { $A.Electron.sendMessage('bindScreenshotKey', {key}); }; -// 翻译 -$A.apiTranslate = (data) => { - if ($A.isJson(data)) { - for (let key in data) { - if (!data.hasOwnProperty(key)) continue; - data[key] = $A.apiTranslate(data[key]); - } - } else if ($A.isArray(data)) { - data.forEach((val, index) => { - data[index] = $A.apiTranslate(val); - }); - } else if (typeof data === 'string' && /__L\((.*?)\)__/.test(data)) { - data = data.replace(/__L\((.*?)\)__/g, (match, p1) => { - return $L(p1) - }) - } - return data -} - Vue.prototype.$A = $A; Vue.prototype.$L = $L; Vue.prototype.$Electron = $A.Electron; diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index f0461fc8c..975ddd709 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -167,7 +167,6 @@ export default { if (params.encrypt === true && result.encrypted) { result = await dispatch("pgpDecryptApi", result.encrypted) } - result = $A.apiTranslate(result) const {ret, data, msg} = result if (ret === -1) { state.userId = 0 @@ -3541,7 +3540,7 @@ export default { if (result.type === "encrypt" && result.encrypted) { result = await dispatch("pgpDecryptApi", result.encrypted) } - const msgDetail = $A.apiTranslate($A.formatMsgBasic(result)); + const msgDetail = $A.formatMsgBasic(result); const {type, msgId} = msgDetail; switch (type) { case "open":