"""Internationalisation package — exposes _(), setup_i18n(), get_language()."""

from __future__ import annotations

from .translator import (
    SUPPORTED_LANGUAGES,
    Translator,
    _cached_translate,
    clear_translation_cache,
    get_language,
    setup_i18n,
)


def _(key: str, **kwargs: object) -> str:
    """Return the translated string for *key* in the current locale.

    When no keyword arguments are supplied (static UI labels), the result is
    served from an ``lru_cache`` keyed on *(key, current_language)* for fast
    repeated access.  Dynamic strings (those needing placeholder substitution)
    bypass the cache and call ``translate()`` directly.
    """
    t = Translator.get_instance()
    if not kwargs:
        return _cached_translate(key, t.language)
    return t.translate(key, **kwargs)


__all__ = [
    "_",
    "setup_i18n",
    "get_language",
    "clear_translation_cache",
    "SUPPORTED_LANGUAGES",
]
