From a659f0831a7ae80d789713bc89e3fa20f03fcc7b Mon Sep 17 00:00:00 2001 From: sight <26325820+Sight-wcg@users.noreply.github.com> Date: Fri, 27 Jun 2025 17:11:05 +0800 Subject: [PATCH] =?UTF-8?q?wip(i18n):=20=E5=88=A0=E9=99=A4=20$t=20?= =?UTF-8?q?=E5=8F=AF=E5=8F=98=E9=95=BF=E5=8F=82=E6=95=B0=E9=87=8D=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/i18n.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/modules/i18n.js b/src/modules/i18n.js index b06532da..bd27e199 100644 --- a/src/modules/i18n.js +++ b/src/modules/i18n.js @@ -194,7 +194,6 @@ layui.define('lay', function(exports) { }, GLOBAL.i18n); // 读取全局预设配置,确保打包后的版本初始调用时机 var OBJECT_REPLACE_REGEX = /\{(\w+)\}/g; - var INDEX_REPLACE_REGEX = /\{(\d+)\}/g; /** * 获取对象中指定路径的值,类似于 lodash 的 _.get 方法(简易版) @@ -284,7 +283,6 @@ layui.define('lay', function(exports) { * @param {any[]} [args] 可选的占位符替换参数: * - 对象形式:用于替换 `{key}` 形式的占位符; * - 数组形式:用于替换 `{0}`, `{1}` 等占位符; - * - 可变参数:用于替换 `{0}`, `{1}` 等占位符。 * @returns {string} 翻译后的文本 * * @example 使用对象替换命名占位符 @@ -298,12 +296,6 @@ layui.define('lay', function(exports) { * hello: '{0} world' * } * i18n.$t('message.hello', ['Hello']) - * - * @example 使用变长参数替换索引占位符 - * message: { - * hello: '{0} world' - * } - * i18n.$t('message.hello', 'Hello') */ i18n.translation = function(key) { var options = config; @@ -325,12 +317,6 @@ layui.define('lay', function(exports) { result = result.replace(OBJECT_REPLACE_REGEX, function(match, key) { return opts[key] !== undefined ? opts[key] : match; }); - }else{ - // 处理可变参数,替换占位符 {0}, {1}... - result = result.replace(INDEX_REPLACE_REGEX, function(match, index) { - var arg = args[index + 1]; - return arg !== undefined ? arg : match; - }); } }