def _translate_page_into(page, language, default=None):
    # Optimisation shortcut: No need to dive into translations if page already
    # what we want
    try:
        if page.language == language:
            return page

        if language is not None:
            translations = dict(
                (t.language, t) for t in page.available_translations())
            if language in translations:
                return translations[language]
    except AttributeError:
        pass

    if hasattr(default, '__call__'):
        return default(page=page)
    return default


# ------------------------------------------------------------------------
Return the translation for a given page
dataset/ETHPy150Open feincms/feincms/feincms/templatetags/feincms_page_tags.py/_translate_page_into