<commit_before>(function () {
    "use strict";

    function LanguagesOverviewController($timeout, $location, notificationsService, localizationService) {

        var vm = this;

        vm.page = {};
        vm.languages = [];
        vm.labels = {};

        vm.addLanguage = addLanguage;
        vm.editLanguage = editLanguage;
        vm.deleteLanguage = deleteLanguage;

        function init() {

            vm.loading = true;

            // localize labels
            var labelKeys = [
                "treeHeaders_languages",
                "general_mandatory",
                "general_default",
            ];

            localizationService.localizeMany(labelKeys).then(function (values) {
                vm.labels.languages = values[0];
                vm.labels.mandatory = values[1];
                vm.labels.general = values[2];
                // set page name
                vm.page.name = vm.labels.languages;
            });

            $timeout(function () {

                vm.languages = [
                    {  
                        "id": 1,
                        "cultureDisplayName": "English (United States)",
                        "culture": "en-US",
                        "isDefault": true,
                        "isMandatory": true
                    },
                    {
                        "id": 2,
                        "cultureDisplayName": "Danish",
                        "culture": "da-DK",
                        "isDefault": false,
                        "isMandatory": true
                    },
                    {
                        "id": 3,
                        "cultureDisplayName": "Spanish (Spain)",
                        "culture": "es-ES",
                        "isDefault": false,
                        "isMandatory": false
                    },
                    {
                        "id": 4,
                        "cultureDisplayName": "French (France)",
                        "culture": "fr-FR",
                        "isDefault": false,
                        "isMandatory": false
                    },
                    {
                        "id": 5,
                        "cultureDisplayName": "German (Germany)",
                        "culture": "de-DE",
                        "isDefault": false,
                        "isMandatory": true
                    }
                ];

                vm.loading = false;

            }, 1000);

            /*
            $timeout(function () {
                navigationService.syncTree({ tree: "languages", path: "-1" });
            });
            */
        }

        function addLanguage() {
            $location.search('create', null);
            $location.path("/settings/languages/edit/-1").search("create", "true");
        }

        function editLanguage(language) {
            $location.search('create', null);
            $location.path("/settings/languages/edit/" + language.id);
        }

        function deleteLanguage(language, event) {
            confirm("Are you sure you want to delete " + language.cultureDisplayName + "?");
            language.deleteButtonState = "busy";
            $timeout(function(){
                var index = vm.languages.indexOf(language);
                vm.languages.splice(index, 1);
            }, 1000);
            event.preventDefault()
            event.stopPropagation();
        }

        init();

    }

    angular.module("umbraco").controller("Umbraco.Editors.Languages.OverviewController", LanguagesOverviewController);

})();
<commit_msg>only delete language when allowed<commit_after>(function () {
    "use strict";

    function LanguagesOverviewController($timeout, $location, notificationsService, localizationService) {

        var vm = this;

        vm.page = {};
        vm.languages = [];
        vm.labels = {};

        vm.addLanguage = addLanguage;
        vm.editLanguage = editLanguage;
        vm.deleteLanguage = deleteLanguage;

        function init() {

            vm.loading = true;

            // localize labels
            var labelKeys = [
                "treeHeaders_languages",
                "general_mandatory",
                "general_default",
            ];

            localizationService.localizeMany(labelKeys).then(function (values) {
                vm.labels.languages = values[0];
                vm.labels.mandatory = values[1];
                vm.labels.general = values[2];
                // set page name
                vm.page.name = vm.labels.languages;
            });

            $timeout(function () {

                vm.languages = [
                    {  
                        "id": 1,
                        "cultureDisplayName": "English (United States)",
                        "culture": "en-US",
                        "isDefault": true,
                        "isMandatory": true
                    },
                    {
                        "id": 2,
                        "cultureDisplayName": "Danish",
                        "culture": "da-DK",
                        "isDefault": false,
                        "isMandatory": true
                    },
                    {
                        "id": 3,
                        "cultureDisplayName": "Spanish (Spain)",
                        "culture": "es-ES",
                        "isDefault": false,
                        "isMandatory": false
                    },
                    {
                        "id": 4,
                        "cultureDisplayName": "French (France)",
                        "culture": "fr-FR",
                        "isDefault": false,
                        "isMandatory": false
                    },
                    {
                        "id": 5,
                        "cultureDisplayName": "German (Germany)",
                        "culture": "de-DE",
                        "isDefault": false,
                        "isMandatory": true
                    }
                ];

                vm.loading = false;

            }, 1000);

            /*
            $timeout(function () {
                navigationService.syncTree({ tree: "languages", path: "-1" });
            });
            */
        }

        function addLanguage() {
            $location.search('create', null);
            $location.path("/settings/languages/edit/-1").search("create", "true");
        }

        function editLanguage(language) {
            $location.search('create', null);
            $location.path("/settings/languages/edit/" + language.id);
        }

        function deleteLanguage(language, event) {
            var confirmed = confirm("Are you sure you want to delete " + language.cultureDisplayName + "?");
            if(confirmed) {
                language.deleteButtonState = "busy";
                $timeout(function(){
                    var index = vm.languages.indexOf(language);
                    vm.languages.splice(index, 1);
                }, 1000);
            }
            event.preventDefault()
            event.stopPropagation();
        }

        init();

    }

    angular.module("umbraco").controller("Umbraco.Editors.Languages.OverviewController", LanguagesOverviewController);

})();

{'fraction_non_alphanumeric': 0.11536351165980796, 'fraction_numerical': 0.005212620027434842, 'mean_word_length': 1.0754341019072018, 'pattern_counts': {'":': 50, '<': 3, '<?xml version=': 0, '>': 3, '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': '6744476', 'n_tokens_mistral': 1830, 'n_tokens_neox': 1611, 'n_words': 301}