lbry-desktop/ui/util/formatAriaLabel.js

33 lines
895 B
JavaScript
Raw Normal View History

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