<commit_before>iD.ui.preset.localized = function(field, context) {
    var dispatch = d3.dispatch('change', 'input'),
        wikipedia = iD.wikipedia(),
        input, localizedInputs, wikiTitles,
        entity;

    function i(selection) {
        input = selection.selectAll('.localized-main')
            .data([0]);

        input.enter().append('input')
            .attr('type', 'text')
            .attr('id', 'preset-input-' + field.id)
            .attr('class', 'localized-main')
            .attr('placeholder', field.placeholder());

        if (field.id === 'name') {
            var preset = context.presets().match(entity, context.graph());
            input.call(d3.combobox().fetcher(
                iD.util.SuggestNames(preset, iD.data.suggestions)
            ));
        }

        input
            .on('input', change(true))
            .on('blur', change())
            .on('change', change());

        var translateButton = selection.selectAll('.localized-add')
            .data([0]);

        translateButton.enter()
            .append('button')
            .attr('class', 'button-input-action localized-add minor')
            .call(iD.svg.Icon('#icon-plus'))
            .call(bootstrap.tooltip()
                .title(t('translate.translate'))
                .placement('left'));

        translateButton
            .on('click', addBlank);

        localizedInputs = selection.selectAll('.localized-wrap')
            .data([0]);

        localizedInputs.enter().append('div')
            .attr('class', 'localized-wrap');
    }

    function addBlank() {
        d3.event.preventDefault();
        var data = localizedInputs.selectAll('div.entry').data();
        data.push({ lang: '', value: '' });
        localizedInputs.call(render, data);
    }

    function change(onInput) {
        return function() {
            var t = {};
            t[field.key] = d3.select(this).value() || undefined;
            dispatch.change(t, onInput);
        };
    }
<commit_msg>Use user language for default translated names<commit_after>iD.ui.preset.localized = function(field, context) {
    var dispatch = d3.dispatch('change', 'input'),
        wikipedia = iD.wikipedia(),
        input, localizedInputs, wikiTitles,
        entity;

    function i(selection) {
        input = selection.selectAll('.localized-main')
            .data([0]);

        input.enter().append('input')
            .attr('type', 'text')
            .attr('id', 'preset-input-' + field.id)
            .attr('class', 'localized-main')
            .attr('placeholder', field.placeholder());

        if (field.id === 'name') {
            var preset = context.presets().match(entity, context.graph());
            input.call(d3.combobox().fetcher(
                iD.util.SuggestNames(preset, iD.data.suggestions)
            ));
        }

        input
            .on('input', change(true))
            .on('blur', change())
            .on('change', change());

        var translateButton = selection.selectAll('.localized-add')
            .data([0]);

        translateButton.enter()
            .append('button')
            .attr('class', 'button-input-action localized-add minor')
            .call(iD.svg.Icon('#icon-plus'))
            .call(bootstrap.tooltip()
                .title(t('translate.translate'))
                .placement('left'));

        translateButton
            .on('click', addNew);

        localizedInputs = selection.selectAll('.localized-wrap')
            .data([0]);

        localizedInputs.enter().append('div')
            .attr('class', 'localized-wrap');
    }

    function addNew() {
        d3.event.preventDefault();
        var data = localizedInputs.selectAll('div.entry').data();
        var defaultLang = iD.detect().locale.toLowerCase().split('-')[0];
        var langExists = _.find(data, function(datum) { return datum.lang === defaultLang;});
        var isLangEn = defaultLang.indexOf('en') > -1;
        if (isLangEn || langExists) {
          defaultLang = '';
        }
        data.push({ lang: defaultLang, value: '' });
        localizedInputs.call(render, data);
    }

    function change(onInput) {
        return function() {
            var t = {};
            t[field.key] = d3.select(this).value() || undefined;
            dispatch.change(t, onInput);
        };
    }

{'fraction_non_alphanumeric': 0.16341071018156744, 'fraction_numerical': 0.0036773155596414617, 'mean_word_length': 1.9306397306397307, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5974365', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1204, 'n_words': 205}