2022-01-03 13:41:00 +01:00
|
|
|
import { getTimeAgoStr } from 'util/time';
|
2021-07-22 10:24:25 +02:00
|
|
|
|
|
|
|
export function formatClaimPreviewTitle(title, channelTitle, date, mediaDuration) {
|
|
|
|
// Aria-label value for claim preview
|
2022-01-03 13:41:00 +01:00
|
|
|
let ariaDate = date ? getTimeAgoStr(date, true) : null;
|
2021-07-22 10:24:25 +02:00
|
|
|
let ariaLabelData = title;
|
|
|
|
|
|
|
|
if (mediaDuration) {
|
|
|
|
if (ariaDate) {
|
2021-07-29 18:52:34 +02:00
|
|
|
ariaLabelData = __('%title% by %channelTitle% %ariaDate%, %mediaDuration%', {
|
2021-07-22 10:24:25 +02:00
|
|
|
title,
|
|
|
|
channelTitle,
|
|
|
|
ariaDate,
|
|
|
|
mediaDuration,
|
|
|
|
});
|
|
|
|
} else {
|
2021-07-29 18:52:34 +02:00
|
|
|
ariaLabelData = __('%title% by %channelTitle%, %mediaDuration%', {
|
2021-07-22 10:24:25 +02:00
|
|
|
title,
|
|
|
|
channelTitle,
|
|
|
|
mediaDuration,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ariaDate) {
|
2021-07-29 18:52:34 +02:00
|
|
|
ariaLabelData = __('%title% by %channelTitle% %ariaDate%', { title, channelTitle, ariaDate });
|
2021-07-22 10:24:25 +02:00
|
|
|
} else {
|
2021-07-29 18:52:34 +02:00
|
|
|
ariaLabelData = __('%title% by %channelTitle%', { title, channelTitle });
|
2021-07-22 10:24:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ariaLabelData;
|
|
|
|
}
|