serverinfo
serverinfo copied to clipboard
Not localised uptime days,hours,mins strings
The uptime info contains not localised strings "days", "hours", "minutes", "seconds"
It comes from this function:
private function formatUptime(int $uptime): string {
if ($uptime === -1) {
return 'Unknown';
}
try {
$boot = new \DateTime($uptime . ' seconds ago');
} catch (\Exception $e) {
return 'Unknown';
}
$interval = $boot->diff(new \DateTime());
if ($interval->days > 0) {
return $interval->format('%a days, %h hours, %i minutes, %s seconds');
}
return $interval->format('%h hours, %i minutes, %s seconds');
}
So, localisation tags are to be added there.
I'd like to work on this issue.
Looking at the code, the fix requires extracting the interval values separately and using L10N for the format string:
$days = $interval->days;
$hours = $interval->h;
$minutes = $interval->i;
$seconds = $interval->s;
return $this->l10n->t('%1$d days, %2$d hours, %3$d minutes, %4$d seconds', [$days, $hours, $minutes, $seconds]);