From aaa4d857501493962d33fc7e8225103a967a74b2 Mon Sep 17 00:00:00 2001 From: sight <26325820+Sight-wcg@users.noreply.github.com> Date: Sun, 25 May 2025 14:51:47 +0800 Subject: [PATCH] =?UTF-8?q?wip(i18n):=20=E7=A7=BB=E9=99=A4=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E6=B6=88=E6=81=AF=E4=B8=AD=E7=9A=84=20`lay`?= =?UTF-8?q?=20=E5=91=BD=E5=90=8D=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layui.js | 366 ++++++++++++++++++------------------- src/modules/code.js | 12 +- src/modules/colorpicker.js | 4 +- src/modules/dropdown.js | 2 +- src/modules/flow.js | 4 +- src/modules/form.js | 22 +-- src/modules/laydate.js | 2 +- src/modules/layer.js | 37 ++-- src/modules/laypage.js | 18 +- src/modules/table.js | 22 +-- src/modules/transfer.js | 8 +- src/modules/tree.js | 6 +- src/modules/upload.js | 20 +- src/modules/util.js | 12 +- 14 files changed, 267 insertions(+), 268 deletions(-) diff --git a/src/layui.js b/src/layui.js index 9108e13e..09aee25c 100644 --- a/src/layui.js +++ b/src/layui.js @@ -14,195 +14,193 @@ // 中文国际化消息对象 var zhCN = { locale: 'zh-cn', - lay: { - code: { - copy: '复制代码', - copied: '已复制', - copyError: '复制失败', - maximize: '最大化显示', - restore: '还原显示', - preview: '在新窗口预览' - }, - colorpicker: { - clear: '清除', - confirm: '确定' - }, - dropdown: { - noData: '暂无数据' - }, - flow: { - loadMore: '加载更多', - noMore: '没有更多了' - }, - form: { - select: { - noData: '暂无数据', - noMatch: '无匹配数据', - placeholder: '请选择' - }, - validateMessages: { - required: '必填项不能为空', - phone: '手机号格式不正确', - email: '邮箱格式不正确', - url: '链接格式不正确', - number: '只能填写数字', - date: '日期格式不正确', - identity: '身份证号格式不正确' - }, - verifyErrorPromptTitle: '提示' - }, - // 未使用的字段为保留字段,将来可能会使用 - laydate: { - month: { - long: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], - short: ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'] - }, - week: { - long: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'], - short: ['日', '一', '二', '三', '四', '五', '六'] - }, - time: ['时', '分', '秒'], - selectTime: '选择时间', - startTime: '开始时间', - endTime: '结束时间', - selectDate: '选择日期', - tools: { - confirm: '确定', - clear: '清空', - now: '现在', - reset: '重置' - }, - timeout: { - date: '结束日期不能早于开始日期
请重新选择', - time: '结束时间不能早于开始时间
请重新选择' - }, - invalidDate: '不在有效日期或时间范围内', - formatError: ['日期格式不合法
必须遵循下述格式:
', '
已为你重置'], - preview: '当前选中的结果', - // IE11- Date.prototype.toLocaleDateString 不支持第二个参数,所以此处用函数实现 - panelHeaderFormat: { - year: function (y) { return y + ' 年' }, - month: function (m) { return m + ' 月' }, - monthBeforeYear: false - }, - // 面板中某些字符串拼接使用 - view: { - year: '年', - month: '月', - week: '周', - day: '天' - } - }, - layer: { - confirm: '确定', - cancel: '取消', - defaultTitle: '信息', - prompt: { - InputLengthPrompt: '最多输入 {length} 个字符' - }, - photos: { - noData: '没有图片', - tools:{ - rotate: '旋转', - scaleX: '水平变换', - zoomIn: '放大', - zoomOut: '缩小', - reset: '还原', - close: '关闭' - }, - viewPicture: '查看原图', - urlError: { - prompt: '当前图片地址异常,
是否继续查看下一张?', - confirm: '下一张', - cancel: '不看了' - } - } - }, - laypage: { - prev: '上一页', - next: '下一页', - first: '首页', - last: '尾页', - total: '共 {total} 条', - pagesize: '条/页', - goto: '到第', - page: '页', - confirm: '确定' - }, - table: { - sort: { - asc: '升序', - desc: '降序' - }, - noData: '无数据', - tools:{ - filter: { - title: '筛选列' - }, - export: { - title: '导出', - noDataPrompt: '当前表格无数据', - compatPrompt: '导出功能不支持 IE,请用 Chrome 等高级浏览器导出', - csvText : '导出 CSV 文件' - }, - print: { - title: '打印', - noDataPrompt: '当前表格无数据' - } - }, - dataFormatError: '返回的数据不符合规范,正确的成功状态码应为:"{statusName}": {statusCode}', - xhrError: '请求异常,错误提示:{msg}' - }, - transfer: { - noData: '无数据', + code: { + copy: '复制代码', + copied: '已复制', + copyError: '复制失败', + maximize: '最大化显示', + restore: '还原显示', + preview: '在新窗口预览' + }, + colorpicker: { + clear: '清除', + confirm: '确定' + }, + dropdown: { + noData: '暂无数据' + }, + flow: { + loadMore: '加载更多', + noMore: '没有更多了' + }, + form: { + select: { + noData: '暂无数据', noMatch: '无匹配数据', - title: ['列表一', '列表二'], - searchPlaceholder: '关键词搜索' + placeholder: '请选择' }, - tree: { - defaultNodeName: '未命名', - noData: '无数据', - deleteNodePrompt: '确认删除"{name}"节点吗?' + validateMessages: { + required: '必填项不能为空', + phone: '手机号格式不正确', + email: '邮箱格式不正确', + url: '链接格式不正确', + number: '只能填写数字', + date: '日期格式不正确', + identity: '身份证号格式不正确' }, - upload: { - fileType: { - file: '文件', - image: '图片', - video: '视频', - audio: '音频' - }, - validateMessages: { - fileExtensionError: '选择的{fileType}中包含不支持的格式', - filesOverLengthLimit: '同时最多只能上传: {length} 个文件', - currentFilesLength: '您当前已经选择了: {length} 个文件', - fileOverSizeLimit: '文件大小不能超过 {size}' - }, - chooseText: '{length} 个文件' + verifyErrorPromptTitle: '提示' + }, + laydate: { + // 未使用的字段为保留字段,将来可能会使用 + month: { + long: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], + short: ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'] }, - util: { - timeAgo: { - days: '{days} 天前', - hours: '{hours} 小时前', - minutes: '{minutes} 分钟前', - future: '未来', - justNow: '刚刚' + week: { + long: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'], + short: ['日', '一', '二', '三', '四', '五', '六'] + }, + time: ['时', '分', '秒'], + selectTime: '选择时间', + startTime: '开始时间', + endTime: '结束时间', + selectDate: '选择日期', + tools: { + confirm: '确定', + clear: '清空', + now: '现在', + reset: '重置' + }, + timeout: { + date: '结束日期不能早于开始日期
请重新选择', + time: '结束时间不能早于开始时间
请重新选择' + }, + invalidDate: '不在有效日期或时间范围内', + formatError: ['日期格式不合法
必须遵循下述格式:
', '
已为你重置'], + preview: '当前选中的结果', + // IE11- Date.prototype.toLocaleDateString 不支持第二个参数,所以此处用函数实现 + panelHeaderFormat: { + year: function (y) { return y + ' 年' }, + month: function (m) { return m + ' 月' }, + monthBeforeYear: false + }, + // 面板中某些字符串拼接使用 + view: { + year: '年', + month: '月', + week: '周', + day: '天' + } + }, + layer: { + confirm: '确定', + cancel: '取消', + defaultTitle: '信息', + prompt: { + InputLengthPrompt: '最多输入 {length} 个字符' + }, + photos: { + noData: '没有图片', + tools:{ + rotate: '旋转', + scaleX: '水平变换', + zoomIn: '放大', + zoomOut: '缩小', + reset: '还原', + close: '关闭' }, - toDateString: { - meridiem: function(hours, minutes){ - var hm = hours * 100 + minutes; - if (hm < 600) { - return '凌晨'; - } else if (hm < 900) { - return '早上'; - } else if (hm < 1100) { - return '上午'; - } else if (hm < 1300) { - return '中午'; - } else if (hm < 1800) { - return '下午'; - } - return '晚上'; + viewPicture: '查看原图', + urlError: { + prompt: '当前图片地址异常,
是否继续查看下一张?', + confirm: '下一张', + cancel: '不看了' + } + } + }, + laypage: { + prev: '上一页', + next: '下一页', + first: '首页', + last: '尾页', + total: '共 {total} 条', + pagesize: '条/页', + goto: '到第', + page: '页', + confirm: '确定' + }, + table: { + sort: { + asc: '升序', + desc: '降序' + }, + noData: '无数据', + tools:{ + filter: { + title: '筛选列' + }, + export: { + title: '导出', + noDataPrompt: '当前表格无数据', + compatPrompt: '导出功能不支持 IE,请用 Chrome 等高级浏览器导出', + csvText : '导出 CSV 文件' + }, + print: { + title: '打印', + noDataPrompt: '当前表格无数据' + } + }, + dataFormatError: '返回的数据不符合规范,正确的成功状态码应为:"{statusName}": {statusCode}', + xhrError: '请求异常,错误提示:{msg}' + }, + transfer: { + noData: '无数据', + noMatch: '无匹配数据', + title: ['列表一', '列表二'], + searchPlaceholder: '关键词搜索' + }, + tree: { + defaultNodeName: '未命名', + noData: '无数据', + deleteNodePrompt: '确认删除"{name}"节点吗?' + }, + upload: { + fileType: { + file: '文件', + image: '图片', + video: '视频', + audio: '音频' + }, + validateMessages: { + fileExtensionError: '选择的{fileType}中包含不支持的格式', + filesOverLengthLimit: '同时最多只能上传: {length} 个文件', + currentFilesLength: '您当前已经选择了: {length} 个文件', + fileOverSizeLimit: '文件大小不能超过 {size}' + }, + chooseText: '{length} 个文件' + }, + util: { + timeAgo: { + days: '{days} 天前', + hours: '{hours} 小时前', + minutes: '{minutes} 分钟前', + future: '未来', + justNow: '刚刚' + }, + toDateString: { + meridiem: function(hours, minutes){ + var hm = hours * 100 + minutes; + if (hm < 600) { + return '凌晨'; + } else if (hm < 900) { + return '早上'; + } else if (hm < 1100) { + return '上午'; + } else if (hm < 1300) { + return '中午'; + } else if (hm < 1800) { + return '下午'; } + return '晚上'; } } } @@ -215,7 +213,7 @@ version: false, // 是否在模块请求时加入版本号参数(以更新模块缓存) i18n:{ locale: 'zh-cn', // 全局内置语言 - messages: { // 全局国际化消息对象,格式为:{locale: {namespace:{component:{...}}}} + messages: { // 全局国际化消息对象 'zh-cn': zhCN } } diff --git a/src/modules/code.js b/src/modules/code.js index d94841ec..3b0f8c52 100644 --- a/src/modules/code.js +++ b/src/modules/code.js @@ -201,7 +201,7 @@ layui.define(['lay', 'util', 'element', 'tabs', 'form'], function(exports){ var tools = { copy: { className: 'file-b', - title: [layui.$t('lay.code.copy')], + title: [layui.$t('code.copy')], event: function(obj){ var code = util.unescape(finalCode(options.code)); var hasOnCopy = typeof options.onCopy === 'function'; @@ -215,14 +215,14 @@ layui.define(['lay', 'util', 'element', 'tabs', 'form'], function(exports){ if(ret === false) return; } - layer.msg(layui.$t('lay.code.copied'), {icon: 1}); + layer.msg(layui.$t('code.copied'), {icon: 1}); }, error: function() { if(hasOnCopy){ var ret = options.onCopy(code, false); if(ret === false) return; } - layer.msg(layui.$t('lay.code.copyError'), {icon: 2}); + layer.msg(layui.$t('code.copyError'), {icon: 2}); } }); } @@ -277,7 +277,7 @@ layui.define(['lay', 'util', 'element', 'tabs', 'form'], function(exports){ $.extend(tools, { 'full': { className: 'screen-full', - title: [layui.$t('lay.code.maximize'), layui.$t('lay.code.restore')], + title: [layui.$t('code.maximize'), layui.$t('code.restore')], event: function(obj){ var el = obj.elem; var elemView = el.closest('.'+ CONST.ELEM_PREVIEW); @@ -302,7 +302,7 @@ layui.define(['lay', 'util', 'element', 'tabs', 'form'], function(exports){ }, 'window': { className: 'release', - title: [layui.$t('lay.code.preview')], + title: [layui.$t('code.preview')], event: function(obj){ util.openWin({ content: finalCode(options.code) @@ -563,7 +563,7 @@ layui.define(['lay', 'util', 'element', 'tabs', 'form'], function(exports){ if(options.copy && !options.preview){ var copyElem = $([ '', - '', + '', '' ].join('')); diff --git a/src/modules/colorpicker.js b/src/modules/colorpicker.js index fe259121..5ab5bb10 100644 --- a/src/modules/colorpicker.js +++ b/src/modules/colorpicker.js @@ -285,8 +285,8 @@ layui.define(['jquery', 'lay'], function(exports) { ,'' ,'' ,'
' - ,'' - ,'' + ,'' + ,'' ,'' ,'
'].join('')) diff --git a/src/modules/dropdown.js b/src/modules/dropdown.js index ee6f7d9e..cf498217 100644 --- a/src/modules/dropdown.js +++ b/src/modules/dropdown.js @@ -181,7 +181,7 @@ layui.define(['jquery', 'laytpl', 'lay', 'util'], function(exports) { if(options.data.length > 0 ){ eachItemView(elemUl, options.data) } else { - elemUl.html('
  • ' + layui.$t('lay.dropdown.noData') + '
  • '); + elemUl.html('
  • ' + layui.$t('dropdown.noData') + '
  • '); } return elemUl; }; diff --git a/src/modules/flow.js b/src/modules/flow.js index 8cf1bb45..e3c190d0 100644 --- a/src/modules/flow.js +++ b/src/modules/flow.js @@ -20,8 +20,8 @@ layui.define('jquery', function(exports) { var scrollElem = $(options.scrollElem || document); // 滚动条所在元素 var threshold = 'mb' in options ? options.mb : 50; // 临界距离 var isAuto = 'isAuto' in options ? options.isAuto : true; // 否自动滚动加载 - var moreText = options.moreText || layui.$t('lay.flow.loadMore'); // 手动加载时,加载更多按钮文案 - var end = options.end || layui.$t('lay.flow.noMore'); // “末页”显示文案 + var moreText = options.moreText || layui.$t('flow.loadMore'); // 手动加载时,加载更多按钮文案 + var end = options.end || layui.$t('flow.noMore'); // “末页”显示文案 var direction = options.direction || 'bottom'; var isTop = direction === 'top'; diff --git a/src/modules/form.js b/src/modules/form.js index 914cb74a..3b4107d6 100644 --- a/src/modules/form.js +++ b/src/modules/form.js @@ -31,42 +31,42 @@ layui.define(['lay', 'layer', 'util'], function(exports){ verify: { required: function(value) { if (!/[\S]+/.test(value) || value === undefined || value === null) { - return layui.$t('lay.form.validateMessages.required'); + return layui.$t('form.validateMessages.required'); } }, phone: function(value) { var EXP = /^1\d{10}$/; if (value && !EXP.test(value)) { - return layui.$t('lay.form.validateMessages.phone'); + return layui.$t('form.validateMessages.phone'); } }, email: function(value) { var EXP = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (value && !EXP.test(value)) { - return layui.$t('lay.form.validateMessages.email'); + return layui.$t('form.validateMessages.email'); } }, url: function(value) { var EXP = /^(#|(http(s?)):\/\/|\/\/)[^\s]+\.[^\s]+$/; if (value && !EXP.test(value)) { - return layui.$t('lay.form.validateMessages.url'); + return layui.$t('form.validateMessages.url'); } }, number: function(value){ if (value && isNaN(value)) { - return layui.$t('lay.form.validateMessages.number'); + return layui.$t('form.validateMessages.number'); } }, date: function(value){ var EXP = /^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/; if (value && !EXP.test(value)) { - return layui.$t('lay.form.validateMessages.date'); + return layui.$t('form.validateMessages.date'); } }, identity: function(value) { var EXP = /(^\d{15}$)|(^\d{17}(x|X|\d)$)/; if (value && !EXP.test(value)) { - return layui.$t('lay.form.validateMessages.identity'); + return layui.$t('form.validateMessages.identity'); } } }, @@ -466,7 +466,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){ // 下拉选择框 ,select: function(elem){ - var TIPS = layui.$t('lay.form.select.placeholder'); + var TIPS = layui.$t('form.select.placeholder'); var CLASS = 'layui-form-select'; var TITLE = 'layui-select-title'; var NONE = 'layui-select-none'; @@ -765,7 +765,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){ } }else{ if(none){ - dl.find('.'+NONE)[0] || dl.append('

    ' + layui.$t('lay.form.select.noMatch') + '

    '); + dl.find('.'+NONE)[0] || dl.append('

    ' + layui.$t('form.select.noMatch') + '

    '); } else { dl.find('.'+NONE).remove(); } @@ -956,7 +956,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){ } }); if (arr.length === 0) { - arr.push('
    ' + layui.$t('lay.form.select.noData') + '
    '); + arr.push('
    ' + layui.$t('form.select.noData') + '
    '); } return arr.join(''); }(); @@ -1367,7 +1367,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){ return othis; }(), {tips: 1}); } else if(verType === 'alert') { - layer.alert(errorText, {title: layui.$t('lay.form.verifyErrorPromptTitle'), shadeClose: true}); + layer.alert(errorText, {title: layui.$t('form.verifyErrorPromptTitle'), shadeClose: true}); } // 若返回的为字符或数字,则自动弹出默认提示框;否则由 verify 方法中处理提示 else if(/\b(string|number)\b/.test(typeof errorText)) { diff --git a/src/modules/laydate.js b/src/modules/laydate.js index d5301772..c5bdc483 100644 --- a/src/modules/laydate.js +++ b/src/modules/laydate.js @@ -282,7 +282,7 @@ var i18n = layui.cache.i18n; var message = i18n.messages[i18n.locale]; if(message){ - text[i18n.locale] = message.lay.laydate; + text[i18n.locale] = message.laydate; }else{ window.console && console.log && console.log('layui[laydate]: Locale "' + i18n.locale + '" not found. Please add i18n messages for this locale first.'); } diff --git a/src/modules/layer.js b/src/modules/layer.js index 7c75c77e..b34c505c 100644 --- a/src/modules/layer.js +++ b/src/modules/layer.js @@ -9,6 +9,7 @@ var isLayui = window.layui && layui.define; var $; var win; +var OBJECT_REPLACE_REGEX = /\{(\w+)\}/g; var ready = { getPath: function(){ @@ -150,11 +151,11 @@ var $t = isLayui : function(key){ // 非 layui 环境去除命名空间前缀,从 config.lang 中取值 // TODO 简化版,暂不文档化,不支持配置多个 locale - key = key.replace(/^lay\.layer\./, ''); + key = key.replace(/^layer\./, ''); var result = get(ready.config.lang, key, key); if(typeof result === 'string' && arguments.length > 1) { var opts = arguments[1]; - return result.replace(/\{(\w+)\}/g, function(match, key) { + return result.replace(OBJECT_REPLACE_REGEX, function(match, key) { return opts[key] !== undefined ? opts[key] : match; }) } @@ -226,7 +227,7 @@ var layer = { } return layer.open($.extend({ content: content, - btn: [$t('lay.layer.confirm'), $t('lay.layer.cancel')], + btn: [$t('layer.confirm'), $t('layer.cancel')], yes: yes, btn2: cancel }, type ? {} : options)); @@ -290,7 +291,7 @@ var Class = function(setings){ that.creat(); }; // TODO 临时的同步方案 - ready.config.title = $t('lay.layer.defaultTitle'); + ready.config.title = $t('layer.defaultTitle'); that.index = ++layer.index; that.config.maxWidth = $(win).width() - 15*2; // 初始最大宽度:当前屏幕宽,左右留 15px 边距 that.config = $.extend({}, that.config, ready.config, setings); @@ -334,7 +335,7 @@ Class.pt.config = { shade: 0.3, fixed: true, move: doms[1], - title: $t('lay.layer.defaultTitle'), + title: $t('layer.defaultTitle'), offset: 'auto', area: 'auto', closeBtn: 1, @@ -522,7 +523,7 @@ Class.pt.creat = function(){ switch(config.type){ case 0: - config.btn = ('btn' in config) ? config.btn : $t('lay.layer.confirm'); + config.btn = ('btn' in config) ? config.btn : $t('layer.confirm'); layer.closeAll('dialog'); break; case 2: @@ -1510,7 +1511,7 @@ layer.prompt = function(options, yes){ return layer.open($.extend({ type: 1, - btn: [$t('lay.layer.confirm'),$t('lay.layer.cancel')], + btn: [$t('layer.confirm'),$t('layer.cancel')], content: content, skin: 'layui-layer-prompt' + skin('prompt'), maxWidth: win.width(), @@ -1523,7 +1524,7 @@ layer.prompt = function(options, yes){ yes: function(index){ var value = prompt.val(); if(value.length > (options.maxlength||500)) { - layer.tips($t('lay.layer.prompt.InputLengthPrompt', {length: (options.maxlength || 500)}), prompt, {tips: 1}); + layer.tips($t('layer.prompt.InputLengthPrompt', {length: (options.maxlength || 500)}), prompt, {tips: 1}); } else { yes && yes(value, index, prompt); } @@ -1637,7 +1638,7 @@ layer.photos = function(options, loop, key){ // 不直接弹出 if (!loop) return; } else if (data.length === 0){ - return layer.msg($t('lay.layer.photos.noData')); + return layer.msg($t('layer.photos.noData')); } // 上一张 @@ -1885,12 +1886,12 @@ layer.photos = function(options, loop, key){ if (options.toolbar) { arr.push([ '
    ', - '', - '', - '', - '', - '', - '', + '', + '', + '', + '', + '', + '', '
    ' ].join('')); } @@ -1900,7 +1901,7 @@ layer.photos = function(options, loop, key){ arr.push([''].join('')); } @@ -1922,9 +1923,9 @@ layer.photos = function(options, loop, key){ }, options)); }, function(){ layer.close(dict.loadi); - layer.msg($t('lay.layer.photos.urlError.prompt'), { + layer.msg($t('layer.photos.urlError.prompt'), { time: 30000, - btn: [$t('lay.layer.photos.urlError.confirm'), $t('lay.layer.photos.urlError.cancel')], + btn: [$t('layer.photos.urlError.confirm'), $t('layer.photos.urlError.cancel')], yes: function(){ data.length > 1 && dict.imgnext(true,true); } diff --git a/src/modules/laypage.js b/src/modules/laypage.js index bdbc1af7..7ea46c94 100644 --- a/src/modules/laypage.js +++ b/src/modules/laypage.js @@ -72,8 +72,8 @@ layui.define(function(exports) { groups = config.pages; } - config.prev = 'prev' in config ? config.prev : layui.$t('lay.laypage.prev'); // 上一页文本 - config.next = 'next' in config ? config.next : layui.$t('lay.laypage.next'); // 下一页文本 + config.prev = 'prev' in config ? config.prev : layui.$t('laypage.prev'); // 上一页文本 + config.next = 'next' in config ? config.next : layui.$t('laypage.next'); // 下一页文本 // 计算当前组 var index = config.pages > groups @@ -100,7 +100,7 @@ layui.define(function(exports) { // 首页 if(index > 1 && config.first !== false && groups !== 0){ - pager.push('' + (config.first || 1) +''); + pager.push('' + (config.first || 1) +''); } // 计算当前页码组的起始页 @@ -137,7 +137,7 @@ layui.define(function(exports) { pager.push('...'); } if(groups !== 0){ - pager.push(''+ (config.last || config.pages) +''); + pager.push(''+ (config.last || config.pages) +''); } } @@ -155,7 +155,7 @@ layui.define(function(exports) { count: function(){ var countText = typeof config.countText === 'object' ? countText[0] + config.count + countText[1] - : layui.$t('lay.laypage.total', {total: config.count}); + : layui.$t('laypage.total', {total: config.count}); return ''+ countText +'' }(), @@ -164,7 +164,7 @@ layui.define(function(exports) { limit: function(){ var elemArr = ['', + '', '', '{{# } }}', '', @@ -117,7 +117,7 @@ layui.define(['laytpl', 'form'], function(exports) { // 默认配置 Class.prototype.config = { - title: layui.$t('lay.transfer.title'), + title: layui.$t('transfer.title'), width: 200, height: 360, data: [], // 数据源 @@ -125,8 +125,8 @@ layui.define(['laytpl', 'form'], function(exports) { showSearch: false, // 是否开启搜索 id: '', // 唯一索引,默认自增 index text: { - none: layui.$t('lay.transfer.noData'), - searchNone: layui.$t('lay.transfer.noMatch') + none: layui.$t('transfer.noData'), + searchNone: layui.$t('transfer.noMatch') } }; diff --git a/src/modules/tree.js b/src/modules/tree.js index b1106089..97945216 100644 --- a/src/modules/tree.js +++ b/src/modules/tree.js @@ -108,8 +108,8 @@ layui.define(['form','util'], function(exports) { edit: false, // 是否开启节点的操作图标 text: { - defaultNodeName: layui.$t('lay.tree.defaultNodeName'), // 节点默认名称 - none: layui.$t('lay.tree.noData') // 数据为空时的文本提示 + defaultNodeName: layui.$t('tree.defaultNodeName'), // 节点默认名称 + none: layui.$t('tree.noData') // 数据为空时的文本提示 } }; @@ -577,7 +577,7 @@ layui.define(['form','util'], function(exports) { // 删除 } else { // 兼容性,手动替换括号为 html - var i18nText = layui.$t('lay.tree.deleteNodePrompt', { + var i18nText = layui.$t('tree.deleteNodePrompt', { name: item[customName.title] || '' }); layer.confirm(i18nText, function(index){ diff --git a/src/modules/upload.js b/src/modules/upload.js index 0f49b21c..eac16819 100644 --- a/src/modules/upload.js +++ b/src/modules/upload.js @@ -524,11 +524,11 @@ layui.define(['lay', 'layer'], function(exports) { // 文件类型名称 var typeName = ({ - file: layui.$t('lay.upload.fileType.file'), - images: layui.$t('lay.upload.fileType.image'), - video: layui.$t('lay.upload.fileType.video'), - audio: layui.$t('lay.upload.fileType.audio') - })[options.accept] || layui.$t('lay.upload.fileType.file'); + file: layui.$t('upload.fileType.file'), + images: layui.$t('upload.fileType.image'), + video: layui.$t('upload.fileType.video'), + audio: layui.$t('upload.fileType.audio') + })[options.accept] || layui.$t('upload.fileType.file'); // 校验文件格式 value = value.length === 0 @@ -572,7 +572,7 @@ layui.define(['lay', 'layer'], function(exports) { // 校验失败提示 if(check){ - that.msg(text['check-error'] || layui.$t('lay.upload.validateMessages.fileExtensionError', {fileType: typeName})); + that.msg(text['check-error'] || layui.$t('upload.validateMessages.fileExtensionError', {fileType: typeName})); return elemFile.value = ''; } @@ -598,9 +598,9 @@ layui.define(['lay', 'layer'], function(exports) { return that.msg(typeof text['limit-number'] === 'function' ? text['limit-number'](options, that.fileLength) : ( - layui.$t('lay.upload.validateMessages.filesOverLengthLimit', {length: options.number}) + layui.$t('upload.validateMessages.filesOverLengthLimit', {length: options.number}) + '
    ' - + layui.$t('lay.upload.validateMessages.currentFilesLength', {length: that.fileLength}) + + layui.$t('upload.validateMessages.currentFilesLength', {length: that.fileLength}) )); } @@ -619,7 +619,7 @@ layui.define(['lay', 'layer'], function(exports) { if(limitSize) return that.msg( typeof text['limit-size'] === 'function' ? text['limit-size'](options, limitSize) - : layui.$t('lay.upload.validateMessages.fileOverSizeLimit', {size: limitSize})); + : layui.$t('upload.validateMessages.fileOverSizeLimit', {size: limitSize})); } send(); @@ -644,7 +644,7 @@ layui.define(['lay', 'layer'], function(exports) { var elemFile = that.elemFile; var item = options.item ? options.item : options.elem; var value = files.length > 1 - ? layui.$t('lay.upload.chooseText', {length: files.length}) + ? layui.$t('upload.chooseText', {length: files.length}) : ((files[0] || {}).name || (elemFile[0].value.match(/[^\/\\]+\..+/g)||[]) || ''); if(elemFile.next().hasClass(ELEM_CHOOSE)){ diff --git a/src/modules/util.js b/src/modules/util.js index 84a97814..23849322 100644 --- a/src/modules/util.js +++ b/src/modules/util.js @@ -230,15 +230,15 @@ layui.define('jquery', function(exports) { // 30 天以内,返回「多久前」 if(stamp >= 1000*60*60*24){ - return layui.$t('lay.util.timeAgo.days', {days: (stamp/1000/60/60/24)|0}); + return layui.$t('util.timeAgo.days', {days: (stamp/1000/60/60/24)|0}); } else if(stamp >= 1000*60*60){ - return layui.$t('lay.util.timeAgo.hours', {hours: (stamp/1000/60/60)|0}); + return layui.$t('util.timeAgo.hours', {hours: (stamp/1000/60/60)|0}); } else if(stamp >= 1000*60*3){ // 3 分钟以内为:刚刚 - return layui.$t('lay.util.timeAgo.minutes', {minutes: (stamp/1000/60)|0}); + return layui.$t('util.timeAgo.minutes', {minutes: (stamp/1000/60)|0}); } else if(stamp < 0){ - return layui.$t('lay.util.timeAgo.future'); + return layui.$t('util.timeAgo.future'); } else { - return layui.$t('lay.util.timeAgo.justNow'); + return layui.$t('util.timeAgo.justNow'); } }, @@ -318,7 +318,7 @@ layui.define('jquery', function(exports) { return '晚上'; }; - var meridiem = (options && options.customMeridiem) || layui.$t('lay.util.toDateString.meridiem') || defaultMeridiem; + var meridiem = (options && options.customMeridiem) || layui.$t('util.toDateString.meridiem') || defaultMeridiem; var matches = { yy: function(){return String(years).slice(-2);},