File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change
1
+ import app from '../../common/app' ;
1
2
import dayjs from 'dayjs' ;
3
+ import extractText from './extractText' ;
2
4
3
5
/**
4
6
* The `humanTime` utility converts a date to a localized, human-readable time-
@@ -23,9 +25,9 @@ export default function humanTime(time: dayjs.ConfigType): string {
23
25
// in the string. If it wasn't this year, we'll show the year as well.
24
26
if ( diff < - 30 * day ) {
25
27
if ( d . year ( ) === dayjs ( ) . year ( ) ) {
26
- ago = d . format ( 'D MMM' ) ;
28
+ ago = d . format ( extractText ( app . translator . trans ( 'core.lib.datetime_formats.humanTimeShort' ) ) ) ;
27
29
} else {
28
- ago = d . format ( 'll' ) ;
30
+ ago = d . format ( extractText ( app . translator . trans ( 'core.lib.datetime_formats.humanTimeLong' ) ) ) ;
29
31
}
30
32
} else {
31
33
ago = d . fromNow ( ) ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import PostLoading from './LoadingPost';
5
5
import ReplyPlaceholder from './ReplyPlaceholder' ;
6
6
import Button from '../../common/components/Button' ;
7
7
import ItemList from '../../common/utils/ItemList' ;
8
+ import extractText from '../../common/utils/extractText' ;
8
9
9
10
/**
10
11
* The `PostStream` component displays an infinitely-scrollable wall of posts in
@@ -292,7 +293,7 @@ export default class PostStream extends Component {
292
293
// set the index to the last post.
293
294
this . stream . index = indexFromViewPort !== null ? indexFromViewPort + 1 : this . stream . count ( ) ;
294
295
this . stream . visible = visible ;
295
- if ( period ) this . stream . description = dayjs ( period ) . format ( 'MMMM YYYY' ) ;
296
+ if ( period ) this . stream . description = dayjs ( period ) . format ( extractText ( app . translator . trans ( 'core.lib.datetime_formats.scrubber' ) ) ) ;
296
297
}
297
298
298
299
/**
Original file line number Diff line number Diff line change @@ -655,6 +655,12 @@ core:
655
655
kilo_text : K
656
656
mega_text : M
657
657
658
+ # These translations are used for formatting dates using dayjs.
659
+ datetime_formats :
660
+ humanTimeShort : D MMM
661
+ humanTimeLong : ll
662
+ scrubber : MMMM YYYY
663
+
658
664
# These translations are used to punctuate a series of items.
659
665
series :
660
666
glue_text : " , "
You can’t perform that action at this time.
0 commit comments