Skip to content

Commit 5886967

Browse files
authored
Merge pull request home-assistant#5641 from home-assistant/dev
2 parents eb4ba4f + 032b01a commit 5886967

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+17986
-452
lines changed

build-scripts/gulp/cast.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ gulp.task(
1616
process.env.IS_CAST = "true";
1717
},
1818
"clean-cast",
19+
"translations-enable-merge-backend",
1920
gulp.parallel(
2021
"gen-icons-app",
2122
"gen-icons-mdi",
@@ -34,6 +35,7 @@ gulp.task(
3435
process.env.NODE_ENV = "production";
3536
},
3637
"clean-cast",
38+
"translations-enable-merge-backend",
3739
gulp.parallel("gen-icons-app", "gen-icons-mdi", "build-translations"),
3840
"copy-static-cast",
3941
"webpack-prod-cast",

build-scripts/gulp/demo.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ gulp.task(
1616
process.env.NODE_ENV = "development";
1717
},
1818
"clean-demo",
19+
"translations-enable-merge-backend",
1920
gulp.parallel(
2021
"gen-icons-app",
2122
"gen-icons-mdi",
@@ -35,6 +36,8 @@ gulp.task(
3536
process.env.NODE_ENV = "production";
3637
},
3738
"clean-demo",
39+
// Cast needs to be backwards compatible and older HA has no translations
40+
"translations-enable-merge-backend",
3841
gulp.parallel(
3942
"gen-icons-app",
4043
"gen-icons-mdi",

build-scripts/gulp/download_translations.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const del = require("del");
22
const gulp = require("gulp");
33
const mapStream = require("map-stream");
44

5-
const inDir = "translations";
5+
const inDir = "translations/frontend";
66
const downloadDir = inDir + "/downloads";
77

88
const tasks = [];
@@ -12,7 +12,7 @@ function hasHtml(data) {
1212
}
1313

1414
function recursiveCheckHasHtml(file, data, errors, recKey) {
15-
Object.keys(data).forEach(function(key) {
15+
Object.keys(data).forEach(function (key) {
1616
if (typeof data[key] === "object") {
1717
const nextRecKey = recKey ? `${recKey}.${key}` : key;
1818
recursiveCheckHasHtml(file, data[key], errors, nextRecKey);
@@ -25,7 +25,7 @@ function recursiveCheckHasHtml(file, data, errors, recKey) {
2525
function checkHtml() {
2626
const errors = [];
2727

28-
return mapStream(function(file, cb) {
28+
return mapStream(function (file, cb) {
2929
const content = file.contents;
3030
let error;
3131
if (content) {
@@ -42,19 +42,19 @@ function checkHtml() {
4242
}
4343

4444
let taskName = "clean-downloaded-translations";
45-
gulp.task(taskName, function() {
45+
gulp.task(taskName, function () {
4646
return del([`${downloadDir}/**`]);
4747
});
4848
tasks.push(taskName);
4949

5050
taskName = "check-translations-html";
51-
gulp.task(taskName, function() {
51+
gulp.task(taskName, function () {
5252
return gulp.src(`${downloadDir}/*.json`).pipe(checkHtml());
5353
});
5454
tasks.push(taskName);
5555

5656
taskName = "move-downloaded-translations";
57-
gulp.task(taskName, function() {
57+
gulp.task(taskName, function () {
5858
return gulp.src(`${downloadDir}/*.json`).pipe(gulp.dest(inDir));
5959
});
6060
tasks.push(taskName);

build-scripts/gulp/gallery.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ gulp.task(
1616
process.env.NODE_ENV = "development";
1717
},
1818
"clean-gallery",
19+
"translations-enable-merge-backend",
1920
gulp.parallel("gen-icons-app", "gen-icons-mdi", "build-translations"),
2021
"copy-static-gallery",
2122
"gen-index-gallery-dev",
@@ -30,6 +31,7 @@ gulp.task(
3031
process.env.NODE_ENV = "production";
3132
},
3233
"clean-gallery",
34+
"translations-enable-merge-backend",
3335
gulp.parallel("gen-icons-app", "gen-icons-mdi", "build-translations"),
3436
"copy-static-gallery",
3537
"webpack-prod-gallery",

build-scripts/gulp/translations.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@ const { mapFiles } = require("../util");
1414
const env = require("../env");
1515
const paths = require("../paths");
1616

17-
const inDir = "translations";
17+
const inFrontendDir = "translations/frontend";
18+
const inBackendDir = "translations/backend";
1819
const workDir = "build-translations";
1920
const fullDir = workDir + "/full";
2021
const coreDir = workDir + "/core";
2122
const outDir = workDir + "/output";
23+
let mergeBackend = false;
24+
25+
gulp.task("translations-enable-merge-backend", (done) => {
26+
mergeBackend = true;
27+
done();
28+
});
2229

2330
String.prototype.rsplit = function (sep, maxsplit) {
2431
var split = this.split(sep);
@@ -171,20 +178,32 @@ gulp.task(
171178
* the Lokalise update to translations/en.json will not happen immediately.
172179
*/
173180
gulp.task("build-master-translation", function () {
181+
const src = [path.join(paths.translations_src, "en.json")];
182+
183+
if (mergeBackend) {
184+
src.push(path.join(inBackendDir, "en.json"));
185+
}
186+
174187
return gulp
175-
.src(path.join(paths.translations_src, "en.json"))
188+
.src(src)
176189
.pipe(
177190
transform(function (data, file) {
178191
return lokaliseTransform(data, data, file);
179192
})
180193
)
181-
.pipe(rename("translationMaster.json"))
194+
.pipe(
195+
merge({
196+
fileName: "translationMaster.json",
197+
})
198+
)
182199
.pipe(gulp.dest(workDir));
183200
});
184201

185202
gulp.task("build-merged-translations", function () {
186203
return gulp
187-
.src([inDir + "/*.json", workDir + "/test.json"], { allowEmpty: true })
204+
.src([inFrontendDir + "/*.json", workDir + "/test.json"], {
205+
allowEmpty: true,
206+
})
188207
.pipe(
189208
transform(function (data, file) {
190209
return lokaliseTransform(data, data, file);
@@ -207,7 +226,10 @@ gulp.task("build-merged-translations", function () {
207226
if (lang === "test") {
208227
src.push(workDir + "/test.json");
209228
} else if (lang !== "en") {
210-
src.push(inDir + "/" + lang + ".json");
229+
src.push(inFrontendDir + "/" + lang + ".json");
230+
if (mergeBackend) {
231+
src.push(inBackendDir + "/" + lang + ".json");
232+
}
211233
}
212234
}
213235
return gulp

0 commit comments

Comments
 (0)