<commit_before>define [
    'underscore',
    'jquery',
    'i18next',
    'app/p13n',
    'app/dateformat'
], (
    _,
    $,
    i18n,
    p13n,
    dateformat
) ->

    # Make sure jade runtime is loaded
    if typeof jade != 'object'
        throw new Error "Jade not loaded before app"

    setHelper = (data, name, helper) ->
        if name of data
            return
        data[name] = helper

    class Jade
        getTemplate: (name) ->
            key = "views/templates/#{name}"
            if key not of JST
                throw new Error "template '#{name}' not loaded"
            templateFunc = JST[key]
            return templateFunc

        tAttr: (attr) ->
            return p13n.getTranslatedAttr attr
        tAttrHasLang: (attr) ->
            if not attr
                return false
            return p13n.getLanguage() of attr
        phoneI18n: (num) ->
            if num.indexOf '0' == 0
                # FIXME: make configurable
                num = '+358' + num.substring 1
            num = num.replace /\s/g, ''
            num = num.replace /-/g, ''
            return num
        staticPath: (path) ->
            # Strip leading slash
            if path.indexOf('/') == 0
                path = path.substring 1
            return appSettings.static_path + path
        humanDateRange: (startTime, endTime) ->
            formatted = dateformat.humanizeEventDatetime(
                startTime, endTime, 'small', hasEndTime=false
            )
            return formatted.date
        humanDistance: (meters) ->
            return if meters == Number.MAX_VALUE
                "?"
            else if meters < 1000
                "#{Math.ceil meters }m"
            else
                val = Math.ceil(meters/100).toString()
                [a, b] = [val.slice(0, -1), val.slice(-1)]
                if b != "0"
                    "#{a}.#{b}km"
                else
                    "#{a}km"
        humanShortcomings: (count) ->
            return if count == Number.MAX_VALUE
                "?"
            else if count == 0
                "0"
            else
                i18n.t 'accessibility.shortcoming_count', count: count
        humanDate: (datetime) ->
            res = dateformat.humanizeSingleDatetime datetime
        uppercaseFirst: (val) ->
            val.charAt(0).toUpperCase() + val.slice 1

        mixinHelpers: (data) ->
            setHelper data, 't', i18n.t<commit_msg>Shortcomings better texts.<commit_after>define [
    'underscore',
    'jquery',
    'i18next',
    'app/p13n',
    'app/dateformat'
], (
    _,
    $,
    i18n,
    p13n,
    dateformat
) ->

    # Make sure jade runtime is loaded
    if typeof jade != 'object'
        throw new Error "Jade not loaded before app"

    setHelper = (data, name, helper) ->
        if name of data
            return
        data[name] = helper

    class Jade
        getTemplate: (name) ->
            key = "views/templates/#{name}"
            if key not of JST
                throw new Error "template '#{name}' not loaded"
            templateFunc = JST[key]
            return templateFunc

        tAttr: (attr) ->
            return p13n.getTranslatedAttr attr
        tAttrHasLang: (attr) ->
            if not attr
                return false
            return p13n.getLanguage() of attr
        phoneI18n: (num) ->
            if num.indexOf '0' == 0
                # FIXME: make configurable
                num = '+358' + num.substring 1
            num = num.replace /\s/g, ''
            num = num.replace /-/g, ''
            return num
        staticPath: (path) ->
            # Strip leading slash
            if path.indexOf('/') == 0
                path = path.substring 1
            return appSettings.static_path + path
        humanDateRange: (startTime, endTime) ->
            formatted = dateformat.humanizeEventDatetime(
                startTime, endTime, 'small', hasEndTime=false
            )
            return formatted.date
        humanDistance: (meters) ->
            return if meters == Number.MAX_VALUE
                "?"
            else if meters < 1000
                "#{Math.ceil meters }m"
            else
                val = Math.ceil(meters/100).toString()
                [a, b] = [val.slice(0, -1), val.slice(-1)]
                if b != "0"
                    "#{a}.#{b}km"
                else
                    "#{a}km"
        humanShortcomings: (count) ->
            return if count == Number.MAX_VALUE
                i18n.t 'accessibility.no_data'
            else if count == 0
                i18n.t 'accessibility.no_shortcomings'
            else
                i18n.t 'accessibility.shortcoming_count', count: count
        humanDate: (datetime) ->
            res = dateformat.humanizeSingleDatetime datetime
        uppercaseFirst: (val) ->
            val.charAt(0).toUpperCase() + val.slice 1

        mixinHelpers: (data) ->
            setHelper data, 't', i18n.t
{'fraction_non_alphanumeric': 0.10712136409227684, 'fraction_numerical': 0.017051153460381142, 'mean_word_length': 1.3408450704225352, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3342783', 'n_tokens_mistral': 1474, 'n_tokens_neox': 1372, 'n_words': 366}