<commit_before>var vm = require('vm'),
    _ = require('underscore'),
    uglifyJs = require('uglify-js-papandreou'),
    uglifyAst = require('uglifyast'),
    i18nTools = require('./i18nTools'),
    bootstrapper = module.exports = {};

// Maintained as a function so syntax highlighting works:
function bootstrapperCode() {
    window.INCLUDE = function () {};

    window.GETSTATICURL = function (url) { // , placeHolderValue1, placeHolderValue2, ...
        var placeHolderValues = Array.prototype.slice.call(arguments, 1);
        return url.replace(/\*\*?/g, function ($0) {
            return placeHolderValues.shift();
        });
    };

    var documentElement = document && document.documentElement,
        documentElementLang = documentElement && i18nTools.normalizeLocaleId(documentElement.getAttribute('lang'));

    function findActiveLocaleId() {
        var isSupportedByLocaleId = {};

        if (window.SUPPORTEDLOCALEIDS) {
            for (var i = 0 ; i < SUPPORTEDLOCALEIDS.length ; i += 1) {
                isSupportedByLocaleId[i18nTools.normalizeLocaleId(SUPPORTEDLOCALEIDS[i])] = true;
            }
        }
        function isSupportedLocaleId(localeId) {
            // Assume that all locales are supported if window.SUPPORTEDLOCALEIDS isn't defined
            return !window.SUPPORTEDLOCALEIDS || isSupportedByLocaleId[i18nTools.normalizeLocaleId(localeId)];
        }
        if (documentElementLang && isSupportedLocaleId(documentElementLang)) {
            return documentElementLang;
        }

        // Check the query string for a locale= parameter.
        if (window.location && location.href) {
            var matchLocationHref = location.href.match(/\?(?:|[^#]*&)locale=([\w\-_]+)(?:[&#]|$)/);
            if (matchLocationHref) {
                var queryStringLocaleId = i18nTools.normalizeLocaleId(matchLocationHref[1]);
                if (isSupportedLocaleId(queryStringLocaleId)) {
                    return queryStringLocaleId;
                }
            }
        }

        if (window.LOCALECOOKIENAME) {
            var matchLocaleCookieValue = document.cookie && document.cookie.match(new RegExp("\\b" + LOCALECOOKIENAME.replace(/[\.\+\*\{\}\[\]\(\)\?\^\$]/g, '\\$&') + "=([\\w\\-]+)"));
            if (matchLocaleCookieValue) {
                var cookieLocaleId = i18nTools.normalizeLocaleId(matchLocaleCookieValue[1]);
                if (isSupportedLocaleId(cookieLocaleId)) {
                    return cookieLocaleId;
                }
            }
        }

        if (window.navigator && navigator.language && isSupportedLocaleId(navigator.language)) {
            return i18nTools.normalizeLocaleId(navigator.language);
        }

        if (window.DEFAULTLOCALEID) {
            return DEFAULTLOCALEID;
        }

        if (window.SUPPORTEDLOCALEID && SUPPORTEDLOCALEID.length > 0) {
            return SUPPORTEDLOCALEID[0];
        }

        return 'en_us';
    }

    window.LOCALEID = findActiveLocaleId();<commit_msg>Bootstrapper, findActiveLocaleId: Fixed fallback to SUPPORTEDLOCALEIDS[0] (was mistyped as SUPPORTEDLOCALEID).<commit_after>var vm = require('vm'),
    _ = require('underscore'),
    uglifyJs = require('uglify-js-papandreou'),
    uglifyAst = require('uglifyast'),
    i18nTools = require('./i18nTools'),
    bootstrapper = module.exports = {};

// Maintained as a function so syntax highlighting works:
function bootstrapperCode() {
    window.INCLUDE = function () {};

    window.GETSTATICURL = function (url) { // , placeHolderValue1, placeHolderValue2, ...
        var placeHolderValues = Array.prototype.slice.call(arguments, 1);
        return url.replace(/\*\*?/g, function ($0) {
            return placeHolderValues.shift();
        });
    };

    var documentElement = document && document.documentElement,
        documentElementLang = documentElement && i18nTools.normalizeLocaleId(documentElement.getAttribute('lang'));

    function findActiveLocaleId() {
        var isSupportedByLocaleId = {};

        if (window.SUPPORTEDLOCALEIDS) {
            for (var i = 0 ; i < SUPPORTEDLOCALEIDS.length ; i += 1) {
                isSupportedByLocaleId[i18nTools.normalizeLocaleId(SUPPORTEDLOCALEIDS[i])] = true;
            }
        }
        function isSupportedLocaleId(localeId) {
            // Assume that all locales are supported if window.SUPPORTEDLOCALEIDS isn't defined
            return !window.SUPPORTEDLOCALEIDS || isSupportedByLocaleId[i18nTools.normalizeLocaleId(localeId)];
        }
        if (documentElementLang && isSupportedLocaleId(documentElementLang)) {
            return documentElementLang;
        }

        // Check the query string for a locale= parameter.
        if (window.location && location.href) {
            var matchLocationHref = location.href.match(/\?(?:|[^#]*&)locale=([\w\-_]+)(?:[&#]|$)/);
            if (matchLocationHref) {
                var queryStringLocaleId = i18nTools.normalizeLocaleId(matchLocationHref[1]);
                if (isSupportedLocaleId(queryStringLocaleId)) {
                    return queryStringLocaleId;
                }
            }
        }

        if (window.LOCALECOOKIENAME) {
            var matchLocaleCookieValue = document.cookie && document.cookie.match(new RegExp("\\b" + LOCALECOOKIENAME.replace(/[\.\+\*\{\}\[\]\(\)\?\^\$]/g, '\\$&') + "=([\\w\\-]+)"));
            if (matchLocaleCookieValue) {
                var cookieLocaleId = i18nTools.normalizeLocaleId(matchLocaleCookieValue[1]);
                if (isSupportedLocaleId(cookieLocaleId)) {
                    return cookieLocaleId;
                }
            }
        }

        if (window.navigator && navigator.language && isSupportedLocaleId(navigator.language)) {
            return i18nTools.normalizeLocaleId(navigator.language);
        }

        if (window.DEFAULTLOCALEID) {
            return DEFAULTLOCALEID;
        }

        if (window.SUPPORTEDLOCALEIDS && SUPPORTEDLOCALEIDS.length > 0) {
            return SUPPORTEDLOCALEIDS[0];
        }

        return 'en_us';
    }

    window.LOCALEID = findActiveLocaleId();
{'fraction_non_alphanumeric': 0.12631061598951507, 'fraction_numerical': 0.008682830930537353, 'mean_word_length': 2.424004486819966, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '69929', 'n_tokens_mistral': 1796, 'n_tokens_neox': 1692, 'n_words': 294}