var through = require( 'through2' );
var gutil = require( 'gulp-util' );
var PluginError = gutil.PluginError;
var sanitize = require( 'sanitize-html' );

const PLUGIN_NAME = 'gulp-sanitize-translations.js';

module.exports = function( options )
{
	// Creating a stream through which each file will pass
	var stream = through.obj( function( file, enc, callback )
	{
		if ( file.isBuffer() ) {

			var content = file.contents.toString();
			var parsed = JSON.parse( content );
			var lang = Object.keys( parsed )[0];

			for ( var i in parsed[ lang ] ) {
				parsed[ lang ][ i ] = sanitize( parsed[ lang ][ i ] );
			}

			file.contents = new Buffer( JSON.stringify( parsed ), 'utf-8' );
		}
		// Streams not supported.
		else if ( file.isStream() ) {
			this.emit( 'error', new gutil.PluginError( PLUGIN_NAME, 'Streaming not supported.' ) );
			return callback();
		}

		// Anything else just falls through.
		this.push( file );
		return callback();
	} );

	// returning the file stream
	return stream;
};

@@ -546,16 +546,207 @@
 g %5D ) %7B%0A
+%0A%09%09%09%09if ( Array.isArray( parsed%5B lang %5D%5B i %5D ) ) %7B%0A%09%09%09%09%09for ( var n in parsed%5B lang %5D%5B i %5D ) %7B%0A%09%09%09%09%09%09parsed%5B lang %5D%5B i %5D%5B n %5D = sanitize( parsed%5B lang %5D%5B i %5D%5B n %5D );%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%09else %7B%0A%09
 %09%09%09%09pars
@@ -796,16 +796,22 @@
  i %5D );%0A
+%09%09%09%09%7D%0A
 %09%09%09%7D%0A%0A%09%09

Fix translation sanitizing to work for plurals.