def suggest_source_locale()

in src/wagtail_localize_smartling/utils.py [0:0]


def suggest_source_locale(project: "Project") -> tuple[str, str] | None:
    """
    Return a tuple of language code and label for a suggested Locale from
    WAGTAIL_CONTENT_LANGUAGES that would match the Smartling project's source
    locale. The Locale doesn't have to exist, it just needs to be creatable. If
    no compatible locale is found, return None.
    """
    from .models import Project

    project = Project.get_current()
    try:
        language_code = get_supported_content_language_variant(project.source_locale_id)
    except LookupError:
        return None

    content_languages = get_content_languages()
    return (language_code, content_languages[language_code])