From 67f57a7f90f5bc80f2659d1fb3ca067147359e27 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 9 Dec 2023 07:32:24 -0500 Subject: [PATCH 1/2] Avoid passing null value to number_format() in Module\Admin\Federation - Address part of https://github.com/friendica/friendica/issues/13699#issuecomment-1848363608 --- src/Module/Admin/Federation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Module/Admin/Federation.php b/src/Module/Admin/Federation.php index 51b83ccb4a..7263057e53 100644 --- a/src/Module/Admin/Federation.php +++ b/src/Module/Admin/Federation.php @@ -185,8 +185,8 @@ class Federation extends BaseAdmin $gserver['platform'] = $systems[$platform]['name']; $gserver['totallbl'] = DI::l10n()->tt('%2$s total system' , '%2$s total systems' , $gserver['total'], number_format($gserver['total'])); - $gserver['monthlbl'] = DI::l10n()->tt('%2$s active user last month' , '%2$s active users last month' , $gserver['month'] ?? 0, number_format($gserver['month'])); - $gserver['halfyearlbl'] = DI::l10n()->tt('%2$s active user last six months' , '%2$s active users last six months' , $gserver['halfyear'] ?? 0, number_format($gserver['halfyear'])); + $gserver['monthlbl'] = DI::l10n()->tt('%2$s active user last month' , '%2$s active users last month' , $gserver['month'] ?? 0, number_format($gserver['month'] ?? 0)); + $gserver['halfyearlbl'] = DI::l10n()->tt('%2$s active user last six months' , '%2$s active users last six months' , $gserver['halfyear'] ?? 0, number_format($gserver['halfyear'] ?? 0)); $gserver['userslbl'] = DI::l10n()->tt('%2$s registered user' , '%2$s registered users' , $gserver['users'], number_format($gserver['users'])); $gserver['postslbl'] = DI::l10n()->tt('%2$s locally created post or comment', '%2$s locally created posts and comments', $gserver['posts'], number_format($gserver['posts'])); From 0b95f39c228023504ed7736ac8461fe47b10b5d4 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 9 Dec 2023 07:42:15 -0500 Subject: [PATCH 2/2] Allow count to be a float in L10n->tt() - Address part of https://github.com/friendica/friendica/issues/13699#issuecomment-1848363608 --- src/Core/L10n.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Core/L10n.php b/src/Core/L10n.php index 80ef832715..ec1cf41112 100644 --- a/src/Core/L10n.php +++ b/src/Core/L10n.php @@ -308,13 +308,13 @@ class L10n * * @param string $singular * @param string $plural - * @param int $count + * @param float $count * @param array $vars Variables to interpolate in the translation string * * @return string * @throws \Exception */ - public function tt(string $singular, string $plural, int $count, ...$vars): string + public function tt(string $singular, string $plural, float $count, ...$vars): string { $s = null; @@ -361,9 +361,9 @@ class L10n * * @return bool */ - private function stringPluralSelectDefault(int $n): bool + private function stringPluralSelectDefault(float $n): bool { - return $n != 1; + return intval($n) != 1; } /**