import chess

from . import ru, en

LANGUAGES = {
    "ru": ru.THEMES,
    "en": en.THEMES,
}

PIECE_SYMBOLS = {
    "ru": ru.PIECE_SYMBOLS,
    "en": en.PIECE_SYMBOLS,
}


def get_theme_name(key: str, lang: str = "ru") -> str:
    """Получить название темы на нужном языке."""
    themes = LANGUAGES.get(lang, LANGUAGES["ru"])
    return themes.get(key, key)


def format_piece_square(piece: chess.Piece, square: chess.Square, lang: str = "ru") -> str:
    """Форматирует фигуру и поле: 'Кe6' (ru) / 'Ne6' (en)."""
    symbols = PIECE_SYMBOLS.get(lang, PIECE_SYMBOLS["ru"])
    symbol = symbols.get(piece.piece_type, "")
    return f"{symbol}{chess.square_name(square)}"
