<commit_before># -*- coding: utf-8 -*-
from classytags.arguments import Argument
from classytags.core import Tag, Options
from django import template
from django.template.defaultfilters import safe
from classytags.helpers import InclusionTag
from django.core.urlresolvers import reverse

register = template.Library()


class RenderPlaceholder(Tag):
    name = 'render_placeholder'
    options = Options(
        Argument('placeholder'),
        Argument('width', default=None, required=False),
        'language',
        Argument('language', default=None, required=False),
    )

    def render_tag(self, context, placeholder, width, language=None):
        request = context.get('request', None)
        if not request:
            return ''
        if not placeholder:
            return ''
        return safe(placeholder.render(context, width, lang=language))
register.tag(RenderPlaceholder)


class CMSEditableObject(InclusionTag):
    template = 'cms/toolbar/model_attribute_noedit.html'
    edit_template = 'cms/toolbar/model_attribute_edit.html'
    name = 'show_editable_model'
    options = Options(
        Argument('instance'),
        Argument('attribute'),
    )

    def _is_editable(self, request):
        return (request and hasattr(request, 'toolbar') and
                request.toolbar.edit_mode)

    def get_template(self, context, **kwargs):
        if self._is_editable(context.get('request', None)):
            return self.edit_template
        return self.template

    def get_context(self, context, instance, attribute):
        context['item'] = getattr(instance, attribute, '')
        context['instance'] = instance
        context['opts'] = instance._meta
        context['admin_url'] = reverse('admin:%s_%s_change' % (
            instance._meta.app_label, instance._meta.module_name),
                                       args=(instance.pk,))
        return context

<commit_msg>Add language<commit_after># -*- coding: utf-8 -*-
from classytags.arguments import Argument
from classytags.core import Tag, Options
from django import template
from django.template.defaultfilters import safe
from classytags.helpers import InclusionTag
from django.core.urlresolvers import reverse

register = template.Library()


class RenderPlaceholder(Tag):
    name = 'render_placeholder'
    options = Options(
        Argument('placeholder'),
        Argument('width', default=None, required=False),
        'language',
        Argument('language', default=None, required=False),
    )

    def render_tag(self, context, placeholder, width, language=None):
        request = context.get('request', None)
        if not request:
            return ''
        if not placeholder:
            return ''
        return safe(placeholder.render(context, width, lang=language))
register.tag(RenderPlaceholder)


class CMSEditableObject(InclusionTag):
    template = 'cms/toolbar/model_attribute_noedit.html'
    edit_template = 'cms/toolbar/model_attribute_edit.html'
    name = 'show_editable_model'
    options = Options(
        Argument('instance'),
        Argument('attribute'),
        Argument('language', default=None, required=False),
    )

    def _is_editable(self, request):
        return (request and hasattr(request, 'toolbar') and
                request.toolbar.edit_mode)

    def get_template(self, context, **kwargs):
        if self._is_editable(context.get('request', None)):
            return self.edit_template
        return self.template

    def get_context(self, context, instance, attribute, language):
        context['item'] = getattr(instance, attribute, '')
        context['instance'] = instance
        context['opts'] = instance._meta
        context['admin_url'] = reverse('admin:%s_%s_change' % (
            instance._meta.app_label, instance._meta.module_name),
                                       args=(instance.pk,))
        if language:
            context['admin_url'] += "?language=%s" % language
        return context


{'fraction_non_alphanumeric': 0.11002506265664161, 'fraction_numerical': 0.0005012531328320802, 'mean_word_length': 3.0030090270812435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3087472', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1034, 'n_words': 246}