diff --git a/index.php b/index.php index 01af69c..464f950 100644 --- a/index.php +++ b/index.php @@ -255,6 +255,21 @@ $catalogOverviewCountLabel = count($photos) . ' фото'; function h(string $v): string { return htmlspecialchars($v, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } function assetUrl(string $path): string { $f=__DIR__ . '/' . ltrim($path,'/'); $v=is_file($f)?(string)filemtime($f):(string)time(); return $path . '?v=' . rawurlencode($v); } function limitText(string $text, int $len): string { return function_exists('mb_substr') ? mb_substr($text, 0, $len) : substr($text, 0, $len); } +function commentCountLabel(int $count): string +{ + $mod100 = $count % 100; + $mod10 = $count % 10; + if ($mod100 >= 11 && $mod100 <= 14) { + return $count . ' комментариев'; + } + if ($mod10 === 1) { + return $count . ' комментарий'; + } + if ($mod10 >= 2 && $mod10 <= 4) { + return $count . ' комментария'; + } + return $count . ' комментариев'; +} function buildTopicTreePublic(array $topics): array { @@ -595,8 +610,8 @@ function outputWatermarked(string $path, string $mime): never 0): ?>