Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,553 changed files
with
67,691 additions
and
17,694 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ | |
.DS_Store | ||
.cache | ||
yarn-error.log | ||
/gulp/tasks/client/vendor/tmp-gamejolt.iss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
var through = require('through2'); | ||
var gutil = require('gulp-util'); | ||
var PluginError = gutil.PluginError; | ||
|
||
const PLUGIN_NAME = 'gulp-rename-langs.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 keys = Object.keys(parsed); | ||
var lang = keys[0]; | ||
|
||
// Changes en-us to en_US. | ||
var pieces = lang.split(/\-/); | ||
if (pieces.length > 1) { | ||
lang = pieces[0] + '_' + pieces[1].toUpperCase(); | ||
parsed[lang] = parsed[keys[0]]; | ||
delete parsed[keys[0]]; | ||
file.contents = new Buffer(JSON.stringify(parsed), 'utf-8'); | ||
} | ||
} else if (file.isStream()) { | ||
// Streams not supported. | ||
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
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]) { | ||
if (Array.isArray(parsed[lang][i])) { | ||
for (var n in parsed[lang][i]) { | ||
parsed[lang][i][n] = sanitize(parsed[lang][i][n]); | ||
} | ||
} else { | ||
parsed[lang][i] = sanitize(parsed[lang][i]); | ||
} | ||
} | ||
|
||
file.contents = new Buffer(JSON.stringify(parsed), 'utf-8'); | ||
} else if (file.isStream()) { | ||
// Streams not supported. | ||
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
var through = require('through2'); | ||
var gutil = require('gulp-util'); | ||
var PluginError = gutil.PluginError; | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var pofile = require('pofile'); | ||
var _ = require('lodash'); | ||
|
||
const PLUGIN_NAME = 'gulp-split-translations.js'; | ||
|
||
module.exports = function(sections) { | ||
// Creating a stream through which each file will pass | ||
var stream = through.obj(function(file, enc, callback) { | ||
if (file.isBuffer()) { | ||
// If we aren't splitting out sections, just pass through. | ||
if (!Object.keys(sections).length) { | ||
this.push(file); | ||
return callback(); | ||
} | ||
|
||
var content = file.contents.toString(); | ||
var parsed = JSON.parse(content); | ||
var lang = Object.keys(parsed)[0]; | ||
|
||
var poContent = fs.readFileSync( | ||
path.resolve( | ||
__dirname, | ||
'../../../site-translations/' + lang + '/main.po' | ||
), | ||
'utf8' | ||
); | ||
var poParsed = pofile.parse(poContent); | ||
var poItems = _.indexBy(poParsed.items, 'msgid'); | ||
|
||
_.forEach( | ||
sections, | ||
function(sectionPaths, sectionName) { | ||
var sectionReferenceRegex = new RegExp( | ||
'^(' + sectionPaths.join('|') + ')' | ||
); | ||
var sectionJson = {}; | ||
sectionJson[lang] = {}; | ||
|
||
// For each translation term in this language. | ||
for (var i in parsed[lang]) { | ||
var poItem = poItems[i]; | ||
if (poItem) { | ||
var matchingReferences = 0; | ||
for (var j in poItem.references) { | ||
if (poItem.references[j].match(sectionReferenceRegex)) { | ||
++matchingReferences; | ||
} | ||
} | ||
|
||
// We only pull it into the section if ALL the references belong to the section. | ||
// Otherwise we want to put it as part of the "common" translation file. | ||
if (matchingReferences == poItem.references.length) { | ||
sectionJson[lang][i] = parsed[lang][i]; | ||
delete parsed[lang][i]; | ||
} | ||
} | ||
} | ||
|
||
this.push( | ||
new gutil.File({ | ||
cwd: file.cwd, | ||
base: file.base, | ||
path: path.join(path.dirname(file.path), sectionName + '.json'), | ||
contents: new Buffer(JSON.stringify(sectionJson), 'utf-8'), | ||
}) | ||
); | ||
}, | ||
this | ||
); | ||
|
||
file.contents = new Buffer(JSON.stringify(parsed), 'utf-8'); | ||
} else if (file.isStream()) { | ||
// Streams not supported. | ||
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const gulp = require('gulp'); | ||
const plugins = require('gulp-load-plugins')(); | ||
|
||
module.exports = config => { | ||
gulp.task('clean:main', () => { | ||
return gulp | ||
.src(config.buildDir, { read: false, allowEmpty: true }) | ||
.pipe(plugins.clean({ force: true })); | ||
}); | ||
|
||
gulp.task('clean:client', cb => { | ||
if (config.clientBuildDir) { | ||
return gulp | ||
.src(config.clientBuildDir, { read: false, allowEmpty: true }) | ||
.pipe(plugins.clean({ force: true })); | ||
} else { | ||
cb(); | ||
} | ||
}); | ||
|
||
gulp.task('clean', gulp.parallel('clean:main', 'clean:client')); | ||
}; |
Oops, something went wrong.