<commit_before>function applyReplacement(str, replacementHash, nestedKey) {
    if (str.indexOf(o.interpolationPrefix) < 0) return str;

    f.each(replacementHash, function(key, value) {
        if (typeof value === 'object' && value !== null) {
            str = applyReplacement(str, value, nestedKey ? nestedKey + '.' + key : key);
        } else {
            str = str.replace(new RegExp([o.interpolationPrefixEscaped, nestedKey ? nestedKey + '.' + key : key, o.interpolationSuffixEscaped].join(''), 'g'), value);
        }
    });
    return str;
}

function applyReuse(translated, options){
    var opts = f.extend({}, options);
    delete opts.postProcess;

    while (translated.indexOf(o.reusePrefix) != -1) {
        replacementCounter++;
        if (replacementCounter > o.maxRecursion) { break; } // safety net for too much recursion
        var index_of_opening = translated.indexOf(o.reusePrefix);
        var index_of_end_of_closing = translated.indexOf(o.reuseSuffix, index_of_opening) + o.reuseSuffix.length;
        var token = translated.substring(index_of_opening, index_of_end_of_closing);
        var token_sans_symbols = token.replace(o.reusePrefix, '').replace(o.reuseSuffix, '');
        var translated_token = _translate(token_sans_symbols, opts);
        translated = translated.replace(token, translated_token);
    }
    return translated;
}

function hasContext(options) {
    return (options.context && typeof options.context == 'string');
}

function needsPlural(options) {
    return (options.count !== undefined && typeof options.count != 'string' && options.count !== 1);
}

function translate(key, options){
    replacementCounter = 0;
    return _translate(key, options);
}
<commit_msg>Added the ability nest reuse with new options<commit_after>function applyReplacement(str, replacementHash, nestedKey) {
    if (str.indexOf(o.interpolationPrefix) < 0) return str;

    f.each(replacementHash, function(key, value) {
        if (typeof value === 'object' && value !== null) {
            str = applyReplacement(str, value, nestedKey ? nestedKey + '.' + key : key);
        } else {
            str = str.replace(new RegExp([o.interpolationPrefixEscaped, nestedKey ? nestedKey + '.' + key : key, o.interpolationSuffixEscaped].join(''), 'g'), value);
        }
    });
    return str;
}

function applyReuse(translated, options){
    var comma = ',';
    var options_open = '{';
    var options_close = '}';
    var opts = f.extend({}, options);
    delete opts.postProcess;

    while (translated.indexOf(o.reusePrefix) != -1) {
        replacementCounter++;
        if (replacementCounter > o.maxRecursion) { break; } // safety net for too much recursion
        var index_of_opening = translated.indexOf(o.reusePrefix);
        var index_of_end_of_closing = translated.indexOf(o.reuseSuffix, index_of_opening) + o.reuseSuffix.length;
        var token = translated.substring(index_of_opening, index_of_end_of_closing);
        var token_sans_symbols = token.replace(o.reusePrefix, '').replace(o.reuseSuffix, '');
        
        if (token_sans_symbols.indexOf(comma) != -1) {
            var index_of_token_end_of_closing = token_sans_symbols.indexOf(comma);
            if (token_sans_symbols.indexOf(options_open, index_of_token_end_of_closing) != -1 && token_sans_symbols.indexOf(options_close, index_of_token_end_of_closing) != -1) {
                var index_of_opts_opening = token_sans_symbols.indexOf(options_open, index_of_token_end_of_closing);
                var index_of_opts_end_of_closing = token_sans_symbols.indexOf(options_close, index_of_opts_opening) + options_close.length;
                try {
                    opts = f.extend(opts, JSON.parse(token_sans_symbols.substring(index_of_opts_opening, index_of_opts_end_of_closing)));
                    token_sans_symbols = token_sans_symbols.substring(0, index_of_token_end_of_closing);
                } catch (e) {
                }
            }
        }
        
        var translated_token = _translate(token_sans_symbols, opts);
        translated = translated.replace(token, translated_token);
    }
    return translated;
}

function hasContext(options) {
    return (options.context && typeof options.context == 'string');
}

function needsPlural(options) {
    return (options.count !== undefined && typeof options.count != 'string' && options.count !== 1);
}

function translate(key, options){
    replacementCounter = 0;
    return _translate(key, options);
}

{'fraction_non_alphanumeric': 0.1196257518378258, 'fraction_numerical': 0.0026732011583871684, 'mean_word_length': 3.384765625, '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': '1648547', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1351, 'n_words': 267}