wip(i18n): 删除 $t 可变长参数重载

pull/2698/head
sight 2025-06-27 17:11:05 +08:00
parent 25be3c9736
commit a659f0831a
1 changed files with 0 additions and 14 deletions

View File

@ -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;
});
}
}