wip(i18n): util 国际化

pull/2695/head
sight 2025-05-23 20:13:59 +08:00
parent 0820272bc4
commit f2c7f6c73b
2 changed files with 41 additions and 20 deletions

View File

@ -14,11 +14,6 @@
var zhCn = {
locale: 'zh-cn',
lay: {
common: {
noData: '暂无数据',
noMatch: '无匹配数据',
placeholder: '请选择'
},
code: {
copy: '复制代码',
copied: '已复制',
@ -53,7 +48,7 @@
date: '日期格式不正确',
identity: '身份证号格式不正确'
},
verifyErrorPromptTitle: '提示',
verifyErrorPromptTitle: '提示'
},
// 未使用的字段为保留字段,将来可能会使用
laydate: {
@ -102,7 +97,7 @@
cancel: '取消',
defaultTitle: '信息',
prompt: {
InputLengthPrompt: '最多输入 {length} 个字符',
InputLengthPrompt: '最多输入 {length} 个字符'
},
photos: {
noData: '没有图片',
@ -166,7 +161,7 @@
tree: {
defaultNodeName: '未命名',
noData: '无数据',
deleteNodePrompt: '确认删除该节点 ({name}) 吗?',
deleteNodePrompt: '确认删除该节点 ({name}) 吗?'
},
upload: {
fileType: {
@ -183,6 +178,32 @@
},
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 '晚上';
}
}
}
}
}
// 基础配置

View File

@ -230,15 +230,15 @@ layui.define('jquery', function(exports) {
// 30 天以内,返回「多久前」
if(stamp >= 1000*60*60*24){
return ((stamp/1000/60/60/24)|0) + ' ' + layui.$t('天前');
return ((stamp/1000/60/60/24)|0) + layui.$t('lay.util.timeAgo.days');
} else if(stamp >= 1000*60*60){
return ((stamp/1000/60/60)|0) + ' ' + layui.$t('小时前');
return ((stamp/1000/60/60)|0) + layui.$t('lay.util.timeAgo.hours');
} else if(stamp >= 1000*60*3){ // 3 分钟以内为:刚刚
return ((stamp/1000/60)|0) + ' ' + layui.$t('分钟前');
return ((stamp/1000/60)|0) + layui.$t('lay.util.timeAgo.minutes');
} else if(stamp < 0){
return layui.$t('未来');
return layui.$t('lay.util.timeAgo.future');
} else {
return layui.$t('刚刚');
return layui.$t('lay.util.timeAgo.justNow');
}
},
@ -305,20 +305,20 @@ layui.define('jquery', function(exports) {
var defaultMeridiem = function(hours, minutes){
var hm = hours * 100 + minutes;
if (hm < 600) {
return layui.$t('凌晨');
return '凌晨';
} else if (hm < 900) {
return layui.$t('早上');
return '早上';
} else if (hm < 1100) {
return layui.$t('上午');
return '上午';
} else if (hm < 1300) {
return layui.$t('中午');
return '中午';
} else if (hm < 1800) {
return layui.$t('下午');
return '下午';
}
return layui.$t('晚上');
return '晚上';
};
var meridiem = (options && options.customMeridiem) || defaultMeridiem;
var meridiem = (options && options.customMeridiem) || layui.$t('lay.util.toDateString.meridiem') || defaultMeridiem;
var matches = {
yy: function(){return String(years).slice(-2);},