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

    angular
        .module('app.core')
        .controller('CoreController', Core);

    Core.$inject = ['$scope', '$translate', 'socket', 'wlfgAppTitle', 'user', 'amMoment'];

    function Core($scope, $translate, socket, wlfgAppTitle, user, amMoment) {
        $scope.wlfgAppTitle = wlfgAppTitle;


        $scope.setLanguage = function (key) {
            $translate.use(key);
            $scope.currentLanguage = key;
            amMoment.changeLocale(key);
        };

        $scope.user = user.get({param: "profile"});
        getUnreadMessageCount();

        $scope.$watch("user", function () {
            if ($scope.user && $scope.user.language && $scope.user.language !== "") {
                $scope.currentLanguage = $scope.user.language;
                $translate.use($scope.user.language);
                amMoment.changeLocale($scope.user.language);
            } else {
                $scope.currentLanguage = 'en';
                $translate.use('en');
                amMoment.changeLocale($translate.use());
            }
        }, true);
        
        //If new message capture it 
        socket.forward('newMessage', $scope);

        $scope.$on('socket:newMessage', function (ev, message) {
            getUnreadMessageCount();
        });

        $scope.$on('updateMessageCount', function () {
            getUnreadMessageCount();
        });

        function getUnreadMessageCount() {
            user.get({param: "unreadMessageCount"},function(unreadMessageCount){
                if($scope.unreadMessageCount && $scope.unreadMessageCount.count != unreadMessageCount.count){
                    $scope.unreadMessageCount = unreadMessageCount;
                }else if($scope.unreadMessageCount===undefined){
                    $scope.unreadMessageCount = unreadMessageCount;
                }
            });
        }

        /* Get user ads with profile ? */
        /*user.query({param: "guildAds"}, function (guildAds) {
            $scope.user.guildAds = [];
            $.each(guildAds, function (i, guild) {
                $scope.user.guildAds.push(guild.name + '-' + guild.realm + '-' + guild.region);
            });
        });*/
        /* I don't remember why :D */
    }
})();<commit_msg>Language switcher<commit_after>(function () {
    'use strict';

    angular
        .module('app.core')
        .controller('CoreController', Core);

    Core.$inject = ['$scope', '$translate', 'socket', 'wlfgAppTitle', 'user', 'amMoment'];

    function Core($scope, $translate, socket, wlfgAppTitle, user, amMoment) {
        $scope.wlfgAppTitle = wlfgAppTitle;


        $scope.setLanguage = function (key) {
            $translate.use(key);
            $scope.currentLanguage = key;
            amMoment.changeLocale(key);
        };

        $scope.user = user.get({param: "profile"});
        getUnreadMessageCount();

        $scope.$watch("user", function () {
            if ($scope.user && $scope.user.language && $scope.user.language !== "") {
                $scope.currentLanguage = $scope.user.language;
                $translate.use($scope.user.language);
                amMoment.changeLocale($scope.user.language);
            } else {
                $scope.currentLanguage = $translate.use() || $translate.preferredLanguage();
                amMoment.changeLocale($translate.use() || $translate.preferredLanguage());
            }
        }, true);
        
        //If new message capture it 
        socket.forward('newMessage', $scope);

        $scope.$on('socket:newMessage', function (ev, message) {
            getUnreadMessageCount();
        });

        $scope.$on('updateMessageCount', function () {
            getUnreadMessageCount();
        });

        function getUnreadMessageCount() {
            user.get({param: "unreadMessageCount"},function(unreadMessageCount){
                if($scope.unreadMessageCount && $scope.unreadMessageCount.count != unreadMessageCount.count){
                    $scope.unreadMessageCount = unreadMessageCount;
                }else if($scope.unreadMessageCount===undefined){
                    $scope.unreadMessageCount = unreadMessageCount;
                }
            });
        }

        /* Get user ads with profile ? */
        /*user.query({param: "guildAds"}, function (guildAds) {
            $scope.user.guildAds = [];
            $.each(guildAds, function (i, guild) {
                $scope.user.guildAds.push(guild.name + '-' + guild.realm + '-' + guild.region);
            });
        });*/
        /* I don't remember why :D */
    }
})();
{'fraction_non_alphanumeric': 0.15030276816608998, 'fraction_numerical': 0.0, 'mean_word_length': 1.981947130883301, 'pattern_counts': {'":': 0, '<': 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': '1514748', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1243, 'n_words': 202}