<commit_before>from django import template
from resources.models import Page
from django.utils import translation
from django.conf import settings
from django.contrib.sites.models import Site

register = template.Library()

@register.inclusion_tag('resources/menu.html', takes_context=True)
def show_menu(context):
    lang = translation.get_language()
    pages = Page.tree.filter(in_menu=True, language=lang)
    return {'page': context.get('page', None),
            'pages': pages}

@register.inclusion_tag('resources/menu.html', takes_context=True)
def show_menu_below(context, page_pk):
    lang = translation.get_language()
    pages = Page.objects.get(pk=page_pk).get_children().\
                filter(in_menu=True, language=lang)
    return {'page': context.get('page', None),
            'pages': pages}

@register.inclusion_tag('resources/translations.html', takes_context=True)
def translations(context):
    site = Site.objects.get_current()
    language = translation.get_language()
    page = context.get('page', None)
    translations = []
    for l in settings.LANGUAGES:
        code = subdomain = l[0]
        if page is None:
            path = context['request'].path
        else:
            v = page.translation_pool.get_by_language(code)
            if v is not None:
                path = v.get_absolute_url()
            else:
                path = "/"
        if code == settings.LANGUAGE_CODE:
            subdomain = "www"
        translations.append({'code': code, 
                             'url': "http://%s.%s%s" % (subdomain,
                                                        site.domain,
                                                        path),
                             'language': l[1]})
    return locals()<commit_msg>Replace in case the domain has www<commit_after>from django import template
from resources.models import Page
from django.utils import translation
from django.conf import settings
from django.contrib.sites.models import Site

register = template.Library()

@register.inclusion_tag('resources/menu.html', takes_context=True)
def show_menu(context):
    lang = translation.get_language()
    pages = Page.tree.filter(in_menu=True, language=lang)
    return {'page': context.get('page', None),
            'pages': pages}

@register.inclusion_tag('resources/menu.html', takes_context=True)
def show_menu_below(context, page_pk):
    lang = translation.get_language()
    pages = Page.objects.get(pk=page_pk).get_children().\
                filter(in_menu=True, language=lang)
    return {'page': context.get('page', None),
            'pages': pages}

@register.inclusion_tag('resources/translations.html', takes_context=True)
def translations(context):
    site = Site.objects.get_current()
    language = translation.get_language()
    page = context.get('page', None)
    translations = []
    for l in settings.LANGUAGES:
        code = subdomain = l[0]
        if page is None:
            path = context['request'].path
        else:
            v = page.translation_pool.get_by_language(code)
            if v is not None:
                path = v.get_absolute_url()
            else:
                path = "/"
        if code == settings.LANGUAGE_CODE:
            subdomain = "www"
        translations.append({'code': code, 
                             'url': "http://%s.%s%s" % (subdomain,
                                                        site.domain.replace("www.", ""),
                                                        path),
                             'language': l[1]})
    return locals()
{'fraction_non_alphanumeric': 0.11642122811892193, 'fraction_numerical': 0.0011114198388441233, 'mean_word_length': 2.1634446397188047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4998797', 'n_tokens_mistral': 975, 'n_tokens_neox': 956, 'n_words': 219}