mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-09 16:21:51 +00:00
- switches to ES modules in gulp and src - uses dengr's webpack configs and package.json, with modifications - removes gulp/package.json - removes babel stuff - removes gulp-load-plugins, instead importing gulp plugins manually - removes unused and trivial packages - upgrades packages - uses path/posix, for gulp - removes __dirname in favor of relative urls
61 lines
2.1 KiB
JavaScript
61 lines
2.1 KiB
JavaScript
import path from "path/posix";
|
|
import fs from "fs";
|
|
import gulpYaml from "gulp-yaml";
|
|
import YAML from "yaml";
|
|
|
|
import gulpPlumber from "gulp-plumber";
|
|
|
|
const translationsSourceDir = path.join("..", "translations");
|
|
const translationsJsonDir = path.join("..", "src", "js", "built-temp");
|
|
|
|
export default function gulptasksTranslations(gulp) {
|
|
gulp.task("translations.convertToJson", () => {
|
|
return gulp
|
|
.src(path.join(translationsSourceDir, "*.yaml"))
|
|
.pipe(gulpPlumber())
|
|
.pipe(gulpYaml({ space: 2, safe: true }))
|
|
.pipe(gulp.dest(translationsJsonDir));
|
|
});
|
|
|
|
gulp.task("translations.fullBuild", gulp.series("translations.convertToJson"));
|
|
|
|
gulp.task("translations.prepareSteamPage", cb => {
|
|
const files = fs.readdirSync(translationsSourceDir);
|
|
|
|
files
|
|
.filter(name => name.endsWith(".yaml"))
|
|
.forEach(fname => {
|
|
console.log("Loading", fname);
|
|
const languageName = fname.replace(".yaml", "");
|
|
const abspath = path.join(translationsSourceDir, fname);
|
|
|
|
const destpath = path.join(translationsSourceDir, "tmp", languageName + "-store.txt");
|
|
|
|
const contents = fs.readFileSync(abspath, { encoding: "utf-8" });
|
|
const data = YAML.parse(contents);
|
|
|
|
const storePage = data.steamPage;
|
|
|
|
const content = `
|
|
[img]{STEAM_APP_IMAGE}/extras/store_page_gif.gif[/img]
|
|
|
|
${storePage.intro.replace(/\n/gi, "\n\n")}
|
|
|
|
[h2]${storePage.what_others_say}[/h2]
|
|
|
|
[list]
|
|
[*] [i]${storePage.nothernlion_comment}[/i] [b]- Northernlion, YouTube[/b]
|
|
[*] [i]${storePage.notch_comment}[/i] [b]- Notch[/b]
|
|
[*] [i]${storePage.steam_review_comment}[/i] [b]- Steam User[/b]
|
|
[/list]
|
|
`;
|
|
|
|
fs.writeFileSync(destpath, content.replace(/(\n[ \t\r]*)/gi, "\n").trim(), {
|
|
encoding: "utf-8",
|
|
});
|
|
});
|
|
|
|
cb();
|
|
});
|
|
}
|