from typing import Union
from pathlib import Path


def filename(
    dictionary_folder: Union[str, Path],
    *,
    target_language: str = "en",
    source_language: str = "auto",
) -> str:
    """
    Generate a toolbox translation dictionary file path

    Args:
        dictionary_folder: base directory where dictionaries are saved
        target_language: the language to translate into, for a list of allowed inputs:
            https://cloud.google.com/translate/docs/basic/discovering-supported-languages
        source_language: the language the text to translate is in, if None, assumes it is "auto"

    Returns:
        A toolbox translation dictionary file path

    """
    if source_language is None:
        source_language = "auto"
    dictionary_name = f"dictionary_{source_language.lower()}_to_{target_language.lower()}.json"
    if isinstance(dictionary_folder, str):
        dictionary_folder = Path(dictionary_folder)
    return str(dictionary_folder / dictionary_name)