<commit_before>
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var messageFormat = require('gulp-messageformat');
var insert = require('gulp-insert');

module.exports = function (gulpConfig) {
	var files = gulpConfig.files;

	gulp.task('locale', function () {

		function parseLocale(language) {
			return (
				gulp.src(['./app/locale/' + language + '/*.json'])
					.pipe(plumber())
					.pipe(messageFormat({locale: language, global: 'that'}))
					.pipe(plumber.stop())
					.pipe(insert.wrap(
						'(function () {var $IMA = {}; if ((typeof window !== "undefined") && (window !== null)) { window.$IMA = window.$IMA || {}; $IMA = window.$IMA; } var that = $IMA || {};',
						' return that.i18n; })();'
					))
					.pipe(gulp.dest(files.locale.dest.client))
					.pipe(insert.wrap('module.exports =', ''))
					.pipe(gulp.dest(files.locale.dest.server))
			);
		}

		var locales = files.locale.src.map(function (language) {
			return parseLocale(language);
		});

		return locales[locales.length - 1];
	});
};
<commit_msg>#! update locale build task for new source structure<commit_after>
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var messageFormat = require('gulp-messageformat');
var insert = require('gulp-insert');
var rename = require('gulp-rename');

module.exports = function (gulpConfig) {
	var files = gulpConfig.files;

	gulp.task('locale', function () {

		function parseLocale(language, selector) {
			return (
				gulp.src(selector)
					.pipe(plumber())
					.pipe(rename(function(path) {
						path.basename = path.basename.replace(new RegExp(language, 'gi'), '')
					}))
					.pipe(messageFormat({locale: language, global: 'that'}))
					.pipe(plumber.stop())
					.pipe(insert.wrap(
						'(function () {var $IMA = {}; if ((typeof window !== "undefined") && (window !== null)) { window.$IMA = window.$IMA || {}; $IMA = window.$IMA; } var that = $IMA || {};',
						' return that.i18n; })();'
					))
					.pipe(gulp.dest(files.locale.dest.client))
					.pipe(insert.wrap('module.exports =', ''))
					.pipe(gulp.dest(files.locale.dest.server))
			);
		}

		var locales = Object.keys(files.locale.src).map(function (language) {
			var selector = files.locale.src[language];

			return parseLocale(language, selector);
		});

		return locales[locales.length - 1];
	});
};

{'fraction_non_alphanumeric': 0.19674935842600513, 'fraction_numerical': 0.0025662959794696323, 'mean_word_length': 3.640873015873016, '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': '3048122', 'n_tokens_mistral': 909, 'n_tokens_neox': 769, 'n_words': 147}