Skip to content

Commit

Permalink
fix: time language
Browse files Browse the repository at this point in the history
  • Loading branch information
wangdan-fit2cloud committed Jan 23, 2025
1 parent 663a6ca commit cabd6fb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
6 changes: 6 additions & 0 deletions ui/src/locales/lang/en-US/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@ export default {
remark: 'Remarks',
update: 'Update',
authorize: 'Authorized'
},
time: {
daysLater: 'days later',
hoursLater: 'hours later',
expired: 'expired',
expiringSoon: 'expiring soon'
}
}
6 changes: 6 additions & 0 deletions ui/src/locales/lang/zh-CN/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ export default {
remark: '备注',
update: '更新',
authorize: '授权给'
},
time: {
daysLater: '天后',
hoursLater: '小时后',
expired: '已过期',
expiringSoon: '即将到期'
}
}
6 changes: 6 additions & 0 deletions ui/src/locales/lang/zh-Hant/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@ export default {
remark: '備註',
update: '更新',
authorize: '授權給'
},
time: {
daysLater: '天後',
hoursLater: '小時後',
expired: '已過期',
expiringSoon: '即將到期'
}
}
10 changes: 5 additions & 5 deletions ui/src/utils/time.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from 'moment'
import 'moment/dist/locale/zh-cn'
moment.locale('zh-cn')

import { t } from '@/locales'
// 当天日期 YYYY-MM-DD
export const nowDate = moment().format('YYYY-MM-DD')

Expand Down Expand Up @@ -64,15 +64,15 @@ export function fromNowDate(time: any) {
return ''
} else {
if (exceedDay < 7 && exceedDay > 0) {
return exceedDay + '天后'
return exceedDay + t('layout.time.daysLater')
} else {
if (exceedHour < 24 && exceedHour > 0) {
return exceedHour + '小时后'
return exceedHour + t('layout.time.hoursLater')
} else {
if (exceedMin < 0) {
return '已过期'
return t('layout.time.expired')
} else {
return '即将到期'
return t('layout.time.expiringSoon')
}
}
}
Expand Down

0 comments on commit cabd6fb

Please sign in to comment.