fix: decline inspection counts in Russian

This commit is contained in:
nyan404 committed 2026-08-25 03:21:01 +03:00
1 parent b1b1c6bcf0
commit a22d23dcd7
2 files changed
+22 -5

No files matched your search

+17 -5
View File
@@ -52,6 +52,22 @@ def _points_phrase(value: float | int) -> str:
return f"{number} {word}"
def _times_phrase(value: int) -> str:
"""Формирует правильную форму слова «раз» для количества осмотров."""
integer = abs(int(value))
last_two = integer % 100
last = integer % 10
if last_two == 1:
word = "раз"
elif 2 <= last_two <= 4:
word = "раза"
elif last in (2, 3, 4) and not 11 <= last_two <= 14:
word = "раза"
else:
word = "раз"
return f"{value} {word}"
def render_coaching(session: CoachingSession, result: CoachingResult) -> str:
"""
Формирует итоговый текст отчёта за ЛУ/ЗУ-сессию.
@@ -108,13 +124,9 @@ def render_inspection(report: InspectionReport, result: InspectionResult | None
Если ресурсов нет — выводит "0" вместо списка.
"""
result = result or calculate_inspection(report)
if report.inspections == 1:
word = "раз"
else:
word = "раз"
lines = [
"#осмотр",
f"{report.character_name} [{report.character_id}] осмотрел(-а) {report.place} {report.inspections} {word}."
f"{report.character_name} [{report.character_id}] осмотрел(-а) {report.place} {_times_phrase(report.inspections)}."
]
if report.resources:
lines.extend(