<commit_before>module.exports = factory;
var deep = require('deep-get-set');
var _ = require('lodash');
var async = require('async');

function factory(options, callback) {
 return new Construct(options, callback);
}

function Construct(options, callback) {
  var self = this;
  self.options = options;
  self._apos = options.apos;
  self._app = options.app;
  self._pages = options.pages;
  self.universal = options.universal || [];
  self.localized = [ 'title' ].concat(options.localized || []);
  self.locales = options.locales;
  self.defaultLocale = options.defaultLocale;
  self.neverTypes = options.neverTypes || [];
  self._apos.mixinModuleAssets(self, 'localization', __dirname, options);

  self._action = '/apos-localization';

  self._apos.addLocal('aposLocalePicker', function(args) {
    var currentLocale = self._apos._aposLocals.getLocale();
    var currentUrl = self._apos._aposLocals.getUrl();
    var locales = [];
    var availableLanguages = []; //_.keys(self.locales);
    if( args && args.localized && args._edit == undefined){
		availableLanguages = _.keys(args.localized);
	}

    _.each(self.locales, function(label, locale) {
      newUrl = '/' + locale + currentUrl;

      var localeObject = {
        key: locale,
        label: label,
        url: newUrl,
        translated: _.contains(availableLanguages, locale),
        active: (currentLocale === locale)
      };
      locales.push(localeObject);
    });
    return self.render('localePicker', { locales: locales, args: args });
  });

  self.setLocale = function(req, locale) {<commit_msg>improvements for empty page checks<commit_after>module.exports = factory;
var deep = require('deep-get-set');
var _ = require('lodash');
var async = require('async');

function factory(options, callback) {
 return new Construct(options, callback);
}

function Construct(options, callback) {
  var self = this;
  self.options = options;
  self._apos = options.apos;
  self._app = options.app;
  self._pages = options.pages;
  self.universal = options.universal || [];
  self.localized = [ 'title' ].concat(options.localized || []);
  self.locales = options.locales;
  self.defaultLocale = options.defaultLocale;
  self.neverTypes = options.neverTypes || [];
  self._apos.mixinModuleAssets(self, 'localization', __dirname, options);

  self._action = '/apos-localization';

  self._apos.addLocal('aposLocalePicker', function(args) {
  	args = args || {};
    var currentLocale = self._apos._aposLocals.getLocale();
    var currentUrl = self._apos._aposLocals.getUrl();
    var locales = [];
    var availableLanguages = _.keys(self.locales);
    if( args && args.localized && args._edit == undefined){
		availableLanguages = _.keys(args.localized);
	}

    _.each(self.locales, function(label, locale) {
      newUrl = '/' + locale + currentUrl;

      var localeObject = {
        key: locale,
        label: label,
        url: newUrl,
        translated: _.contains(availableLanguages, locale),
        active: (currentLocale === locale)
      };
      locales.push(localeObject);
    });
    return self.render('localePicker', { locales: locales, args: args });
  });

  self.setLocale = function(req, locale) {
{'fraction_non_alphanumeric': 0.1464408905613045, 'fraction_numerical': 0.0, 'mean_word_length': 3.6774193548387095, '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': '5570870', 'n_tokens_mistral': 966, 'n_tokens_neox': 965, 'n_words': 202}