<commit_before>import i18next from 'i18next';
import sha1 from 'sha1';

const t = (...args) => {
    const key = args[0];
    const options = args[1];

    let text = i18next.t(key, options);
    if (typeof text === 'string' && text.length === 0) {
        text = i18next.t(key, { ...options, lng: 'en' });
    }

    return text;
};

const _ = (...args) => {
    if ((args.length === 0) || (typeof args[0] === 'undefined')) {
        return i18next.t.apply(i18next, args);
    }

    const value = args[0];
    const options = args[1] || {};
    const key = sha1(value);
    args[0] = value;

    options.defaultValue = value;

    let text = i18next.t(key, options);
    if (typeof text !== 'string' || text.length === 0) {
        text = i18next.t(key, { ...options, lng: 'en' });
    }

    return text;
};

export default {<commit_msg>Add support for i18next context and plural form<commit_after>import i18next from 'i18next';
import sha1 from 'sha1';

const t = (...args) => {
    const key = args[0];
    const options = args[1];

    let text = i18next.t(key, options);
    if (typeof text === 'string' && text.length === 0) {
        text = i18next.t(key, { ...options, lng: 'en' });
    }

    return text;
};

const _ = (...args) => {
    if ((args.length === 0) || (typeof args[0] === 'undefined')) {
        return i18next.t.apply(i18next, args);
    }

    const [value = '', options = {}] = args;
    const key = ((value, options) => {
        const { context, count } = { ...options };
        const containsContext = (context !== undefined) && (context !== null);
        const containsPlural = (typeof count === 'number');
        if (containsContext) {
            value = value + i18next.options.contextSeparator + options.context;
        }
        if (containsPlural) {
            value = value + i18next.options.pluralSeparator + 'plural';
        }
        return sha1(value);
    })(value, options);

    options.defaultValue = value;

    let text = i18next.t(key, options);
    if (typeof text !== 'string' || text.length === 0) {
        text = i18next.t(key, { ...options, lng: 'en' });
    }

    return text;
};

export default {
{'fraction_non_alphanumeric': 0.1813975011568718, 'fraction_numerical': 0.027302174919018974, 'mean_word_length': 2.4154818325434437, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '5731130', 'n_tokens_mistral': 744, 'n_tokens_neox': 707, 'n_words': 189}