@@ -45,7 +45,7 @@ export class MatPaginatorIntlHans extends MatPaginatorIntl {
4545 } ;
4646}
4747
48- export const getReadableDate = ( date : Date ) : string => {
48+ export const getReadableDate = ( date : Date , locale : string ) : string => {
4949 const now = new Date ( ) ;
5050 const years = differenceInYears ( now , date ) ;
5151 const months = differenceInMonths ( now , date ) ;
@@ -54,12 +54,13 @@ export const getReadableDate = (date: Date): string => {
5454 const hours = differenceInHours ( now , date ) ;
5555 const minutes = differenceInMinutes ( now , date ) ;
5656
57- if ( years > 0 ) return `${ years } 年前` ;
58- if ( months > 0 ) return `${ months } 个月前` ;
59- if ( weeks > 0 ) return `${ weeks } 周前` ;
60- if ( days > 0 ) return `${ days } 天前` ;
61- if ( hours > 0 ) return `${ hours } 小时前` ;
62- return `${ minutes } 分钟前` ;
57+ const isHans : boolean = / z h / . test ( locale ) ;
58+ if ( years > 0 ) return `${ years } ${ isHans ? '年前' : 'years ago' } ` ;
59+ if ( months > 0 ) return `${ months } ${ isHans ? '个月前' : 'months ago' } ` ;
60+ if ( weeks > 0 ) return `${ weeks } ${ isHans ? '周前' : 'weeks ago' } ` ;
61+ if ( days > 0 ) return `${ days } ${ isHans ? '天前' : 'days ago' } ` ;
62+ if ( hours > 0 ) return `${ hours } ${ isHans ? '小时前' : 'hours ago' } ` ;
63+ return `${ minutes } ${ isHans ? '分钟前' : 'minutes ago' } ` ;
6364}
6465
6566export interface ISearchHistory {
0 commit comments