<commit_before>'use strict';

/**
 * @ngdoc overview
 * @name Teem
 * @description
 * # Teem
 *
 * Main module of the application.
 */
angular
  .module('Teem', [
    'pasvaz.bindonce',
    'pascalprecht.translate',
    'ngRoute',
    'ngSanitize',
    'ngAnimate',
    'ngCookies',
    'ngMessages',
    'mobile-angular-ui',
    'ui-notification',
    'selectize',
    'ui.bootstrap',
    'monospaced.elastic',
    'angulartics',
    'angulartics.piwik',
    'SwellRTService',
    'hmTouchEvents',
    'ab-base64',
    'angular-toArrayFilter',
    'angularMoment',
    'ngImgCrop',
    'ngFileUpload'
  ]).
  // Application config
  // See config.js.sample for examples
  // WARNING: If you check this line, please check the replace
  // string in gulpfile.js
  value('config', {}). // inject:app:config
  config(['$routeProvider', function($routeProvider) {
    $routeProvider.
      when('/', {
        template: '',
        controller: [
          'SessionSvc', '$location', '$cookies', 'Loading',
          function(SessionSvc, $location, $cookies, Loading) {

            // Looking for cookies to maintain backwards compatibility
            if ($cookies.get('walkthrough')) {
              localStorage.setItem('walkthrough', true);
              $cookies.remove('walkthrough');
            }

            if (localStorage.getItem('walkthrough')) {
              Loading.show(SessionSvc.onLoad(function() {
                $location.path(SessionSvc.users.loggedIn()? '/home/teems' : '/communities');
              }));
            } else {
              $location.path('/walkthrough');
            }
          }
        ]
      });
  }])
  .config(function($translateProvider) {
    $translateProvider
      .useStaticFilesLoader({
        prefix: 'l10n/',
        suffix: '.json'
      })
      .useSanitizeValueStrategy('escaped')
      .registerAvailableLanguageKeys(['en', 'es'], {
        'en_*': 'en',
        'es_*': 'es'
        // When adding more languages, do not forget to add them for "moment"
        // in the vendor.js section of gulpfile.js
      })
      // Do not change order of next two elements
      // https://github.com/angular-translate/angular-translate/issues/920#issuecomment-180550269
      .determinePreferredLanguage()
      .fallbackLanguage('en');
  })
  .run(function(amMoment, $translate) {
    amMoment.changeLocale($translate.proposedLanguage() || $translate.use());
  })
  .filter('base64', function(){
    return window.btoa;
  })
  .filter('escape', function() {
    return window.encodeURIComponent;
  })
  .filter('escapeBase64', function(){
    return function(str){
      return window.encodeURIComponent(
        window.encodeURIComponent(
          window.btoa(str)));
    };
  })
  .filter('unescapeBase64', function(){
    return function(str){
      return window.atob(
        window.decodeURIComponent(
          window.decodeURIComponent(str)));
    };
  });<commit_msg>Use MomentJS default language detector instead of ngTranslate's one.<commit_after>'use strict';

/**
 * @ngdoc overview
 * @name Teem
 * @description
 * # Teem
 *
 * Main module of the application.
 */
angular
  .module('Teem', [
    'pasvaz.bindonce',
    'pascalprecht.translate',
    'ngRoute',
    'ngSanitize',
    'ngAnimate',
    'ngCookies',
    'ngMessages',
    'mobile-angular-ui',
    'ui-notification',
    'selectize',
    'ui.bootstrap',
    'monospaced.elastic',
    'angulartics',
    'angulartics.piwik',
    'SwellRTService',
    'hmTouchEvents',
    'ab-base64',
    'angular-toArrayFilter',
    'angularMoment',
    'ngImgCrop',
    'ngFileUpload'
  ]).
  // Application config
  // See config.js.sample for examples
  // WARNING: If you check this line, please check the replace
  // string in gulpfile.js
  value('config', {}). // inject:app:config
  config(['$routeProvider', function($routeProvider) {
    $routeProvider.
      when('/', {
        template: '',
        controller: [
          'SessionSvc', '$location', '$cookies', 'Loading',
          function(SessionSvc, $location, $cookies, Loading) {

            // Looking for cookies to maintain backwards compatibility
            if ($cookies.get('walkthrough')) {
              localStorage.setItem('walkthrough', true);
              $cookies.remove('walkthrough');
            }

            if (localStorage.getItem('walkthrough')) {
              Loading.show(SessionSvc.onLoad(function() {
                $location.path(SessionSvc.users.loggedIn()? '/home/teems' : '/communities');
              }));
            } else {
              $location.path('/walkthrough');
            }
          }
        ]
      });
  }])
  .config(function($translateProvider) {
    /* Moment.js is better at choosing languages because it looks up navigator.languages
       (drafty but supported by Chrome and Firefox).
       https://www.w3.org/TR/2016/WD-html51-20160310/webappapis.html#language-preferences */
    var preferedLanguage = window.moment.locale();

    $translateProvider
      .useStaticFilesLoader({
        prefix: 'l10n/',
        suffix: '.json'
      })
      .useSanitizeValueStrategy('escaped')
      .registerAvailableLanguageKeys(['en', 'es'], {
        'en_*': 'en',
        'es_*': 'es'
        // When adding more languages, do not forget to add them for "moment"
        // in the vendor.js section of gulpfile.js
      })
      // Do not change order of next two elements
      // https://github.com/angular-translate/angular-translate/issues/920#issuecomment-180550269
      .preferredLanguage(preferedLanguage)
      .fallbackLanguage('en');
  })
  .run(function(amMoment, $translate) {
    amMoment.changeLocale($translate.proposedLanguage() || $translate.use());
  })
  .filter('base64', function(){
    return window.btoa;
  })
  .filter('escape', function() {
    return window.encodeURIComponent;
  })
  .filter('escapeBase64', function(){
    return function(str){
      return window.encodeURIComponent(
        window.encodeURIComponent(
          window.btoa(str)));
    };
  })
  .filter('unescapeBase64', function(){
    return function(str){
      return window.atob(
        window.decodeURIComponent(
          window.decodeURIComponent(str)));
    };
  });
{'fraction_non_alphanumeric': 0.14731927225889552, 'fraction_numerical': 0.00949927547898889, 'mean_word_length': 2.4840157038698822, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, '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': '2702617', 'n_tokens_mistral': 1878, 'n_tokens_neox': 1850, 'n_words': 354}