# Copyright (c) 2026 Krzysztof Rudnicki. MIT licence. """Polish number agreement, and the small text pieces the renderers share. Polish nouns take three forms after a numeral, not two. "1 znak", "2 znaki", "5 znaków" -- and the rule is on the last *two* digits, so 12, 13 and 14 take the many-form while 22, 23 and 24 do not. Getting this wrong is the kind of thing the group notices immediately and mentions every time. """ from __future__ import annotations from typing import Final TEEN_START: Final = 12 TEEN_END: Final = 14 FEW_START: Final = 2 FEW_END: Final = 4 def plural(count: int, one: str, few: str, many: str) -> str: """Pick the Polish form that agrees with a count. Args: count: The number the noun follows. one: The form for exactly 1 ("znak"). few: The form for 2-4 and most numbers ending 2-4 ("znaki"). many: Every other case, including the 12-14 teens ("znaków"). Returns: The bare noun, without the number. """ if count == 1: return one if TEEN_START <= count % 100 <= TEEN_END: return many if FEW_START <= count % 10 <= FEW_END: return few return many def messages(count: int) -> str: """The count and its noun, agreeing: e.g. 3 wiadomości.""" return f"{count} {plural(count, 'wiadomość', 'wiadomości', 'wiadomości')}" def characters(count: int) -> str: """The count and its noun, agreeing: e.g. 44 znaki.""" return f"{count} {plural(count, 'znak', 'znaki', 'znaków')}" def commands(count: int) -> str: """The count and its noun, agreeing: e.g. 4 komendy.""" return f"{count} {plural(count, 'komenda', 'komendy', 'komend')}" def people(count: int) -> str: """The count and its noun, agreeing: e.g. 2 osoby.""" return f"{count} {plural(count, 'osoba', 'osoby', 'osób')}" def days(count: int) -> str: """The count and its noun, agreeing: e.g. 3 dni.""" return f"{count} {plural(count, 'dzień', 'dni', 'dni')}"