Beispiel #1
0
    def test_use_empty_fallbacks_as_default(self):
        cms_languages = {
            1: [
                {
                    "code": "en",
                    "name": "English",
                },
                {
                    "code": "de",
                    "name": "German",
                },
                {
                    "code": "nl",
                    "name": "Dutch",
                },
            ],
            "default": {
                "fallbacks": []
            },
        }

        with self.settings(CMS_LANGUAGES=cms_languages):
            languages = get_languages()
            self.assertListEqual(languages[1][0]["fallbacks"], [])
Beispiel #2
0
def get_secondary_language(current_site=None):
    """Fetch the other language of the current site settings."""
    current_site = current_site or Site.objects.get_current()
    return get_languages()[current_site.id][1]['code']
Beispiel #3
0
def get_primary_language(current_site=None):
    """Fetch the first language of the current site settings."""
    current_site = current_site or Site.objects.get_current()
    return get_languages()[current_site.id][0]['code']
Beispiel #4
0
def get_secondary_lanaguage(current_site=None):
    """Fetch the other language of the current site settings."""
    current_site = current_site or Site.objects.get_current()
    return get_languages()[current_site.id][1]['code']    
Beispiel #5
0
def get_primary_lanaguage(current_site=None):
    """Fetch the first language of the current site settings."""
    current_site = current_site or Site.objects.get_current()
    return get_languages()[current_site.id][0]['code']    
Beispiel #6
0
def get_cms_languages(opts):
    return merge_dict(get_languages(), opts)