Localized d and h

This commit is contained in:
Brian Choromanski
2021-12-06 05:57:37 -05:00
parent bc990cd683
commit 7bca8e508e
2 changed files with 10 additions and 4 deletions

View File

@@ -837,5 +837,11 @@
},
"fillerNewFeature": {
"message": "New! Skip tangents and jokes with the filler category. Enable in options"
},
"dayAbbreviation": {
"message": "d"
},
"hourAbbreviation": {
"message": "h"
}
}

View File

@@ -731,17 +731,17 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
}
/**
* Converts time in hours to 5h 25.1
* Converts time in hours to 2d 5h 25.1
* If less than 1 hour, just returns minutes
*
* @param {float} seconds
* @returns {string}
*/
function getFormattedHours(minutes) {
minutes = Math.round(minutes * 10) / 10
const days = Math.floor(minutes / 3600)
minutes = Math.round(minutes * 10) / 10;
const days = Math.floor(minutes / 3600);
const hours = Math.floor(minutes / 60) % 24;
return (days > 0 ? days + "d " : "") + (hours > 0 ? hours + "h " : "") + (minutes % 60).toFixed(1);
return (days > 0 ? days + chrome.i18n.getMessage("dayAbbreviation") + " " : "") + (hours > 0 ? hours + chrome.i18n.getMessage("hourAbbreviation") + " " : "") + (minutes % 60).toFixed(1);
}
//end of function