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

	angular
		.module('app.services.lang', ['app.services.config', 'ui.router', 'gettext'])
		.factory('Lang', ['$state', '$rootScope', 'gettextCatalog', 'Config', LangFactory]);

	function LangFactory($state, $rootScope, gettextCatalog, Config) {

		var service = {
			language: null,
			defaultLanguage: null,
			languages: Config.languages,
			setLanguage: setLanguage
		};

		activate();

		return service;

		////////////

		function activate() {

			// Highlight untranslated strings
			// gettextCatalog.debug = true;

			$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){
				if (toParams.vocab) {
					// A new vocabulary might mean a new default language.
					// E.g. when switching from Realfagstermer to Mrtermer, the default language
					// should change from 'nb' to 'en'.
					setLanguageFromState(toParams);
				}
			});
		}

		function setLanguage(code) {
			if (service.languages.indexOf(code) === -1) {
				console.error('Invalid language code: ' + code);
				return;
			}
			console.log('[Lang] Changing language to: ' + code);
			service.language = code;
			gettextCatalog.setCurrentLanguage(code);
			$state.go($state.current.name, {lang: code});
		}
<commit_msg>Fix startup language<commit_after>(function() {
    'use strict';

	angular
		.module('app.services.lang', ['app.services.config', 'ui.router', 'gettext'])
		.factory('Lang', ['$state', '$rootScope', 'gettextCatalog', 'Config', LangFactory]);

	function LangFactory($state, $rootScope, gettextCatalog, Config) {

		var service = {
			language: null,
			defaultLanguage: null,
			languages: Config.languages,
			setLanguage: setLanguage
		};

		activate();

		return service;

		////////////

		function activate() {

			service.language = Config.defaultLanguage;
			gettextCatalog.setCurrentLanguage(service.language);

			// Highlight untranslated strings
			// gettextCatalog.debug = true;

			$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){
				if (toParams.vocab) {
					// A new vocabulary might mean a new default language.
					// E.g. when switching from Realfagstermer to Mrtermer, the default language
					// should change from 'nb' to 'en'.
					setLanguageFromState(toParams);
				}
			});
		}

		function setLanguage(code) {
			if (service.languages.indexOf(code) === -1) {
				console.error('Invalid language code: ' + code);
				return;
			}
			console.log('[Lang] Changing language to: ' + code);
			service.language = code;
			gettextCatalog.setCurrentLanguage(code);
			$state.go($state.current.name, {lang: code});
		}

{'fraction_non_alphanumeric': 0.15063861758076635, 'fraction_numerical': 0.0007513148009015778, 'mean_word_length': 3.544368600682594, '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': '6019194', 'n_tokens_mistral': 961, 'n_tokens_neox': 806, 'n_words': 193}