1
mirror of https://github.com/monero-project/monero-gui synced 2024-11-17 14:33:19 +01:00

Utils: simplify for translations

This commit is contained in:
selsta 2020-05-16 17:56:36 +02:00
parent c20a0ef928
commit 527adcba17
No known key found for this signature in database
GPG Key ID: 2EA0A99A8B07AE5E

View File

@ -55,36 +55,14 @@ function ago(epoch) {
var now = new Date().getTime() / 1000;
var delta = now - epoch;
if(delta < 60) {
if (delta <= 1) {
return 1 + " " + qsTr("second ago")
} else {
return Math.floor(delta) + " " + qsTr("seconds ago")
}
} else if (delta >= 60 && delta <= 3600) {
if(delta >= 60 && delta < 120){
return 1 + " " + qsTr("minute ago")
} else {
return parseInt(Math.floor(delta / 60)) + " " + qsTr("minutes ago")
}
} else if (delta >= 3600 && delta <= 86400) {
if(delta >= 3600 && delta < 7200) {
return 1 + " " + qsTr("hour ago")
} else {
return parseInt(Math.floor(delta / 60 / 60)) + " " + qsTr("hours ago")
}
} else if (delta >= 86400){
if(delta >= 86400 && delta < 172800) {
return 1 + " " + qsTr("day ago")
} else {
var _delta = parseInt(Math.floor(delta / 24 / 60 / 60));
if(_delta === 1) {
return 1 + " " + qsTr("day ago")
} else {
return _delta + " " + qsTr("days ago")
}
}
}
if(delta < 60)
return qsTr("%n second(s) ago", "0", Math.floor(delta))
else if (delta >= 60 && delta <= 3600)
return qsTr("%n minute(s) ago", "0", Math.floor(delta / 60))
else if (delta >= 3600 && delta <= 86400)
return qsTr("%n hour(s) ago", "0", Math.floor(delta / 60 / 60))
else if (delta >= 86400)
return qsTr("%n day(s) ago", "0", Math.floor(delta / 24 / 60 / 60))
}
function netTypeToString(){