From cfb84353731faf7ffefaf1173a47632ab127b935 Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 18 Mar 2025 02:13:14 -0700 Subject: [PATCH] Revise formatClientLabel() w/ ngettext --- includes/dashboard.php | 12 ++++++++++-- src/RaspAP/UI/Dashboard.php | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/dashboard.php b/includes/dashboard.php index c6e2d686..ddf8ab93 100755 --- a/includes/dashboard.php +++ b/includes/dashboard.php @@ -58,9 +58,17 @@ function DisplayDashboard(): void $hostapdStatus = ($hostapd[0] == 1) ? "active" : ""; $adblockStatus = ($adblock == true) ? "active" : ""; $wirelessClientActive = ($wirelessClients > 0) ? "active" : "inactive"; - $wirelessClientLabel = $wirelessClients. ' WLAN '.$dashboard->formatClientLabel($wirelessClients); + $wirelessClientLabel = sprintf( + _('%d WLAN %s'), + $wirelessClients, + $dashboard->formatClientLabel($wirelessClients) + ); $ethernetClientActive = ($ethernetClients > 0) ? "active" : "inactive"; - $ethernetClientLabel = $ethernetClients. ' LAN '.$dashboard->formatClientLabel($ethernetClients); + $ethernetClientLabel = sprintf( + _('%d LAN %s'), + $ethernetClients, + $dashboard->formatClientLabel($ethernetClients) + ); $totalClientsActive = ($totalClients > 0) ? "active": "inactive"; $freq5active = $freq24active = ""; $varName = "freq" . str_replace('.', '', $frequency) . "active"; diff --git a/src/RaspAP/UI/Dashboard.php b/src/RaspAP/UI/Dashboard.php index 8b2aad59..73d515c2 100644 --- a/src/RaspAP/UI/Dashboard.php +++ b/src/RaspAP/UI/Dashboard.php @@ -208,7 +208,7 @@ class Dashboard { public function formatClientLabel($clientCount) { - return $clientCount === 1 ? 'client' : 'clients'; + return ngettext('client', 'clients', $clientCount); } /*