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 now = new Date().getTime() / 1000;
var delta = now - epoch; var delta = now - epoch;
if(delta < 60) { if(delta < 60)
if (delta <= 1) { return qsTr("%n second(s) ago", "0", Math.floor(delta))
return 1 + " " + qsTr("second ago") else if (delta >= 60 && delta <= 3600)
} else { return qsTr("%n minute(s) ago", "0", Math.floor(delta / 60))
return Math.floor(delta) + " " + qsTr("seconds ago") else if (delta >= 3600 && delta <= 86400)
} return qsTr("%n hour(s) ago", "0", Math.floor(delta / 60 / 60))
} else if (delta >= 60 && delta <= 3600) { else if (delta >= 86400)
if(delta >= 60 && delta < 120){ return qsTr("%n day(s) ago", "0", Math.floor(delta / 24 / 60 / 60))
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")
}
}
}
} }
function netTypeToString(){ function netTypeToString(){