If the target language still has only one space in all possible combinations, this is the easiest:
(this code must be added to the javascript part of the extension. This code is the content of js/src/forum/index.js on a standard extension structure created with the extension generator for example)
import {extend} from 'flarum/extend';
import PostStreamScrubber from 'flarum/components/PostStreamScrubber';
app.initializers.add('your-vendor-name/your-package-name', () => {
extend(PostStreamScrubber.prototype, 'update', function() {
this.description = this.description.split(' ').reverse().join(' ');
});
});
This code simply reverses the order of all words in the scrubber time label.
If you want to be able to provide your own moment formatting, then you need something like this:
import {extend} from 'flarum/extend';
import PostStreamScrubber from 'flarum/components/PostStreamScrubber';
app.initializers.add('your-vendor-name/your-package-name', () => {
extend(PostStreamScrubber.prototype, 'update', function(returnValue, scrollTop) {
const stream = this.props.stream;
const marginTop = stream.getMarginTop();
const viewportTop = scrollTop + marginTop;
const viewportHeight = $(window).height() - marginTop;
const $items = stream.$('> .PostStream-item[data-index]');
let period = '';
$items.each(function() {
const $this = $(this);
const top = $this.offset().top;
const height = $this.outerHeight(true);
if (top + height < viewportTop) {
return true;
}
if (top > viewportTop + viewportHeight) {
return false;
}
const time = $this.data('time');
if (time) period = time;
});
this.description = period ? moment(period).format('YOUR CUSTOM FORMAT') : '';
});
});
It extends the update method of the scrubber and repeats everything needed to compute the original period variable, and you're then able to apply and format as you want.
This custom code added via extend will run just after the original code, overriding the this.description value. It's worth noting that the each loop runs twice that way, once in the original call, then in the extend call. For extreme performance optimization it might be worth looking at overrideing instead and repeating the whole original code with the format changes, so the loop runs only once. But I wouldn't recommend doing that unless absolutely necessary as it makes more things to check on each Flarum update (if Flarum updates that original method).