mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Initial support for translations
This commit is contained in:
@@ -67,6 +67,9 @@ docs.gulptasksDocs($, gulp, buildFolder);
|
||||
const standalone = require("./standalone");
|
||||
standalone.gulptasksStandalone($, gulp, buildFolder);
|
||||
|
||||
const translations = require("./translations");
|
||||
translations.gulptasksTranslations($, gulp, buildFolder);
|
||||
|
||||
// FIXME
|
||||
// const cordova = require("./cordova");
|
||||
// cordova.gulptasksCordova($, gulp, buildFolder);
|
||||
@@ -74,10 +77,12 @@ standalone.gulptasksStandalone($, gulp, buildFolder);
|
||||
///////////////////// BUILD TASKS /////////////////////
|
||||
|
||||
// Cleans up everything
|
||||
gulp.task("utils.cleanup", () => {
|
||||
gulp.task("utils.cleanBuildFolder", () => {
|
||||
return gulp.src(buildFolder, { read: false }).pipe($.clean({ force: true }));
|
||||
});
|
||||
|
||||
gulp.task("utils.cleanup", $.sequence("utils.cleanBuildFolder", "translations.clear"));
|
||||
|
||||
// Requires no uncomitted files
|
||||
gulp.task("utils.requireCleanWorkingTree", cb => {
|
||||
const output = $.trim(execSync("git status -su").toString("ascii"));
|
||||
@@ -142,6 +147,9 @@ function serve({ standalone }) {
|
||||
// Watch sound files
|
||||
// gulp.watch(["../res_raw/sounds/**/*.mp3", "../res_raw/sounds/**/*.wav"], ["sounds.dev"]);
|
||||
|
||||
// Watch translations
|
||||
gulp.watch("../translations/**/*.yaml", ["translations.convertToJson"]);
|
||||
|
||||
gulp.watch(
|
||||
["../res_raw/sounds/ui/*.mp3", "../res_raw/sounds/ui/*.wav"],
|
||||
$.sequence("sounds.encodeUi", "sounds.copy")
|
||||
@@ -163,11 +171,15 @@ function serve({ standalone }) {
|
||||
gulp.watch("../res_built/atlas/*.json", ["imgres.atlas"]);
|
||||
|
||||
// Watch the build folder and reload when anything changed
|
||||
const extensions = ["html", "js", "png", "jpg", "svg", "mp3", "ico", "woff2"];
|
||||
const extensions = ["html", "js", "png", "jpg", "svg", "mp3", "ico", "woff2", "json"];
|
||||
gulp.watch(extensions.map(ext => path.join(buildFolder, "**", "*." + ext))).on("change", function (e) {
|
||||
return gulp.src(e.path).pipe(browserSync.reload({ stream: true }));
|
||||
});
|
||||
|
||||
gulp.watch("../src/js/translations-built/*.json").on("change", function (e) {
|
||||
return gulp.src(e.path).pipe(browserSync.reload({ stream: true }));
|
||||
});
|
||||
|
||||
// Start the webpack watching server (Will never return)
|
||||
if (standalone) {
|
||||
$.sequence("js.standalone-dev.watch")(() => true);
|
||||
@@ -202,7 +214,7 @@ gulp.task("build.dev", cb => {
|
||||
"sounds.dev",
|
||||
"imgres.copyImageResources",
|
||||
"imgres.copyNonImageResources",
|
||||
"js.dev",
|
||||
"translations.fullBuild",
|
||||
"css.dev",
|
||||
"html.dev"
|
||||
)(cb);
|
||||
@@ -216,6 +228,7 @@ gulp.task("build.standalone.dev", cb => {
|
||||
"sounds.dev",
|
||||
"imgres.copyImageResources",
|
||||
"imgres.copyNonImageResources",
|
||||
"translations.fullBuild",
|
||||
"js.standalone-dev",
|
||||
"css.dev",
|
||||
"html.standalone-dev"
|
||||
@@ -223,7 +236,7 @@ gulp.task("build.standalone.dev", cb => {
|
||||
});
|
||||
|
||||
// Builds everything (staging)
|
||||
gulp.task("step.staging.code", $.sequence("js.staging"));
|
||||
gulp.task("step.staging.code", $.sequence("translations.fullBuild", "js.staging"));
|
||||
gulp.task("step.staging.mainbuild", cb =>
|
||||
$.multiProcess(["utils.copyAdditionalBuildFiles", "step.baseResources", "step.staging.code"], cb, false)
|
||||
);
|
||||
@@ -231,7 +244,7 @@ gulp.task("step.staging.all", $.sequence("step.staging.mainbuild", "css.prod", "
|
||||
gulp.task("build.staging", $.sequence("utils.cleanup", "step.staging.all", "step.postbuild"));
|
||||
|
||||
// Builds everything (prod)
|
||||
gulp.task("step.prod.code", $.sequence("js.prod"));
|
||||
gulp.task("step.prod.code", $.sequence("translations.fullBuild", "js.prod"));
|
||||
gulp.task("step.prod.mainbuild", cb =>
|
||||
$.multiProcess(["utils.copyAdditionalBuildFiles", "step.baseResources", "step.prod.code"], cb, false)
|
||||
);
|
||||
@@ -239,7 +252,7 @@ gulp.task("step.prod.all", $.sequence("step.prod.mainbuild", "css.prod", "html.p
|
||||
gulp.task("build.prod", $.sequence("utils.cleanup", "step.prod.all", "step.postbuild"));
|
||||
|
||||
// Builds everything (standalone-beta)
|
||||
gulp.task("step.standalone-beta.code", $.sequence("js.standalone-beta"));
|
||||
gulp.task("step.standalone-beta.code", $.sequence("translations.fullBuild", "js.standalone-beta"));
|
||||
gulp.task("step.standalone-beta.mainbuild", cb =>
|
||||
$.multiProcess(
|
||||
["utils.copyAdditionalBuildFiles", "step.baseResources", "step.standalone-beta.code"],
|
||||
@@ -254,7 +267,7 @@ gulp.task(
|
||||
gulp.task("build.standalone-beta", $.sequence("utils.cleanup", "step.standalone-beta.all", "step.postbuild"));
|
||||
|
||||
// Builds everything (standalone-prod)
|
||||
gulp.task("step.standalone-prod.code", $.sequence("js.standalone-prod"));
|
||||
gulp.task("step.standalone-prod.code", $.sequence("translations.fullBuild", "js.standalone-prod"));
|
||||
gulp.task("step.standalone-prod.mainbuild", cb =>
|
||||
$.multiProcess(
|
||||
["utils.copyAdditionalBuildFiles", "step.baseResources", "step.standalone-prod.code"],
|
||||
|
||||
@@ -97,6 +97,7 @@
|
||||
"gulp-sftp": "^0.1.5",
|
||||
"gulp-terser": "^1.2.0",
|
||||
"gulp-webserver": "^0.9.1",
|
||||
"gulp-yaml": "^2.0.4",
|
||||
"imagemin-mozjpeg": "^8.0.0",
|
||||
"imagemin-pngquant": "^8.0.0",
|
||||
"jimp": "^0.6.1",
|
||||
|
||||
26
gulp/translations.js
Normal file
26
gulp/translations.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const path = require("path");
|
||||
|
||||
const yaml = require("gulp-yaml");
|
||||
|
||||
const translationsSourceDir = path.join(__dirname, "..", "translations");
|
||||
const translationsJsonDir = path.join(__dirname, "..", "src", "js", "translations-built");
|
||||
|
||||
function gulptasksTranslations($, gulp, buildFolder) {
|
||||
gulp.task("translations.clear", () => {
|
||||
return gulp.src(translationsJsonDir, { read: false }).pipe($.clean({ force: true }));
|
||||
});
|
||||
|
||||
gulp.task("translations.convertToJson", () => {
|
||||
return gulp
|
||||
.src(path.join(translationsSourceDir, "*.yaml"))
|
||||
.pipe($.plumber())
|
||||
.pipe(yaml({ space: 2, safe: true }))
|
||||
.pipe(gulp.dest(translationsJsonDir));
|
||||
});
|
||||
|
||||
gulp.task("translations.fullBuild", $.sequence("translations.convertToJson"));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
gulptasksTranslations,
|
||||
};
|
||||
@@ -2477,6 +2477,13 @@ buffer@^5.2.0, buffer@^5.2.1:
|
||||
base64-js "^1.0.2"
|
||||
ieee754 "^1.1.4"
|
||||
|
||||
bufferstreams@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/bufferstreams/-/bufferstreams-2.0.1.tgz#441b267c2fc3fee02bb1d929289da113903bd5ef"
|
||||
integrity sha512-ZswyIoBfFb3cVDsnZLLj2IDJ/0ppYdil/v2EGlZXvoefO689FokEmFEldhN5dV7R2QBxFneqTJOMIpfqhj+n0g==
|
||||
dependencies:
|
||||
readable-stream "^2.3.6"
|
||||
|
||||
builtin-status-codes@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"
|
||||
@@ -6452,6 +6459,18 @@ gulp-webserver@^0.9.1:
|
||||
tiny-lr "0.1.4"
|
||||
watch "^0.11.0"
|
||||
|
||||
gulp-yaml@^2.0.4:
|
||||
version "2.0.4"
|
||||
resolved "https://registry.yarnpkg.com/gulp-yaml/-/gulp-yaml-2.0.4.tgz#86569e2becc9f5dfc95dc92db5a71a237f4b6ab4"
|
||||
integrity sha512-S/9Ib8PO+jGkCvWDwBUkmFkeW7QM0pp4PO8NNrMEfWo5Sk30P+KqpyXc4055L/vOX326T/b9MhM4nw5EenyX9g==
|
||||
dependencies:
|
||||
bufferstreams "^2.0.1"
|
||||
js-yaml "^3.13.1"
|
||||
object-assign "^4.1.1"
|
||||
plugin-error "^1.0.1"
|
||||
replace-ext "^1.0.0"
|
||||
through2 "^3.0.0"
|
||||
|
||||
gulp@^3.9.1:
|
||||
version "3.9.1"
|
||||
resolved "https://registry.yarnpkg.com/gulp/-/gulp-3.9.1.tgz#571ce45928dd40af6514fc4011866016c13845b4"
|
||||
@@ -12889,7 +12908,7 @@ through2@2.0.3:
|
||||
readable-stream "^2.1.5"
|
||||
xtend "~4.0.1"
|
||||
|
||||
through2@3.0.1, through2@^3.0.1:
|
||||
through2@3.0.1, through2@^3.0.0, through2@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/through2/-/through2-3.0.1.tgz#39276e713c3302edf9e388dd9c812dd3b825bd5a"
|
||||
integrity sha512-M96dvTalPT3YbYLaKaCuwu+j06D/8Jfib0o/PxbVt6Amhv3dUAtW6rTV1jPgJSBG83I/e04Y6xkVdVhSRhi0ww==
|
||||
|
||||
Reference in New Issue
Block a user