def get_parler_languages_from_django_cms(cms_languages=None):
    """
    Converts django CMS' setting CMS_LANGUAGES into PARLER_LANGUAGES. Since
    CMS_LANGUAGES is a strict superset of PARLER_LANGUAGES, we do a bit of
    cleansing to remove irrelevant items.
    """
    valid_keys = ['code', 'fallbacks', 'hide_untranslated',
                  'redirect_on_fallback']
    if cms_languages:
        if sys.version_info < (3, 0, 0):
            int_types = (int, long)
        else:
            int_types = int

        parler_languages = copy.deepcopy(cms_languages)
        for site_id, site_config in cms_languages.items():
            if site_id and (
                    not isinstance(site_id, int_types) and
                    site_id != 'default'
            ):
                del parler_languages[site_id]
                continue

            if site_id == 'default':
                for key, value in site_config.items():
                    if key not in valid_keys:
                        del parler_languages['default'][key]
            else:
                for i, lang_config in enumerate(site_config):
                    for key, value in lang_config.items():
                        if key not in valid_keys:
                            del parler_languages[site_id][i][key]
        return parler_languages
    return None
dataset/ETHPy150Open edoburu/django-parler/parler/utils/conf.py/get_parler_languages_from_django_cms/original