From 114f484faf34a39cad032ce1caf7ae3558af1602 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sun, 15 Sep 2024 00:57:38 +0200 Subject: [PATCH] Chore: Fix build --- .../mapcomplete-changes.json | 99 +++++++++++++------ .../mapcomplete-changes.proto.json | 1 - scripts/ScriptUtils.ts | 31 ++++-- scripts/generateTranslations.ts | 4 +- 4 files changed, 93 insertions(+), 42 deletions(-) diff --git a/assets/themes/mapcomplete-changes/mapcomplete-changes.json b/assets/themes/mapcomplete-changes/mapcomplete-changes.json index 7873f6b663..67501aaefb 100644 --- a/assets/themes/mapcomplete-changes/mapcomplete-changes.json +++ b/assets/themes/mapcomplete-changes/mapcomplete-changes.json @@ -1,13 +1,18 @@ { "id": "mapcomplete-changes", "title": { - "en": "Changes made with MapComplete" + "en": "Changes made with MapComplete", + "de": "Änderungen mit MapComplete" }, "shortDescription": { - "en": "Shows changes made by MapComplete" + "en": "Shows changes made by MapComplete", + "de": "Zeigt die von MapComplete vorgenommenen Änderungen an" }, "description": { - "en": "This maps shows all the changes made with MapComplete" + "en": "This maps shows all the changes made with MapComplete", + "de": "Diese Karte zeigt alle mit MapComplete vorgenommenen Änderungen", + "es": "Este mapa muestra todos los cambios realizados con MapComplete", + "pl": "Ta mapa pokazuje wszystkie zmiany wprowadzone za pomocą MapComplete" }, "icon": "./assets/svg/logo.svg", "hideFromOverview": true, @@ -18,7 +23,8 @@ { "id": "mapcomplete-changes", "name": { - "en": "Changeset centers" + "en": "Changeset centers", + "de": "Changeset-Zentren" }, "minzoom": 0, "source": { @@ -28,41 +34,49 @@ }, "title": { "render": { - "en": "Changeset for {theme}" + "en": "Changeset for {theme}", + "de": "Änderungssatz für {theme}" } }, "description": { - "en": "Shows all MapComplete changes" + "en": "Shows all MapComplete changes", + "de": "Zeigt alle MapComplete-Änderungen", + "es": "Muestra todos los cambios de MapComplete" }, "tagRenderings": [ { "id": "show_changeset_id", "render": { - "en": "Changeset {id}" + "en": "Changeset {id}", + "de": "Änderungssatz {id}" } }, { "id": "contributor", "question": { - "en": "What contributor did make this change?" + "en": "What contributor did make this change?", + "de": "Wer hat zu dieser Änderung beigetragen?" }, "freeform": { "key": "user" }, "render": { - "en": "Change made by {user}" + "en": "Change made by {user}", + "de": "Änderung vorgenommen von {user}" } }, { "id": "theme-id", "question": { - "en": "What theme was used to make this change?" + "en": "What theme was used to make this change?", + "de": "Welches Thema wurde für diese Änderung verwendet?" }, "freeform": { "key": "theme" }, "render": { - "en": "Change with theme {theme}" + "en": "Change with theme {theme}", + "de": "Änderung mit Thema {theme}" } }, { @@ -71,19 +85,23 @@ "key": "locale" }, "question": { - "en": "What locale (language) was this change made in?" + "en": "What locale (language) was this change made in?", + "de": "In welcher Sprache (Locale) wurde diese Änderung vorgenommen?" }, "render": { - "en": "User locale is {locale}" + "en": "User locale is {locale}", + "de": "Die Benutzersprache ist {locale}" } }, { "id": "host", "render": { - "en": "Change with with {host}" + "en": "Change with with {host}", + "de": "Änderung mit {host}" }, "question": { - "en": "What host (website) was this change made with?" + "en": "What host (website) was this change made with?", + "de": "Bei welchem Host (Website) wurde diese Änderung vorgenommen?" }, "freeform": { "key": "host" @@ -104,10 +122,12 @@ { "id": "version", "question": { - "en": "What version of MapComplete was used to make this change?" + "en": "What version of MapComplete was used to make this change?", + "de": "Welche Version von MapComplete wurde verwendet, um diese Änderung vorzunehmen?" }, "render": { - "en": "Made with {editor}" + "en": "Made with {editor}", + "de": "Erstellt mit {editor}" }, "freeform": { "key": "editor" @@ -505,7 +525,10 @@ } ], "question": { - "en": "Themename contains {search}" + "en": "Themename contains {search}", + "de": "Themenname enthält {search}", + "es": "El nombre contiene {search}", + "pl": "Nazwa tematu zawiera {search}" } } ] @@ -521,7 +544,9 @@ } ], "question": { - "en": "Themename does not contain {search}" + "en": "Themename does not contain {search}", + "de": "Themename enthält nicht {search}", + "es": "El nombre del tema no contiene {search}" } } ] @@ -537,7 +562,9 @@ } ], "question": { - "en": "Made by contributor {search}" + "en": "Made by contributor {search}", + "de": "Erstellt von Mitwirkendem {search}", + "es": "Hecho por el colaborador {search}" } } ] @@ -553,7 +580,9 @@ } ], "question": { - "en": "Not made by contributor {search}" + "en": "Not made by contributor {search}", + "de": "Nicht erstellt von Mitwirkendem {search}", + "es": "No realizado por el colaborador {search}" } } ] @@ -570,7 +599,9 @@ } ], "question": { - "en": "Made before {search}" + "en": "Made before {search}", + "de": "Erstellt vor {search}", + "es": "Realizado antes de {search}" } } ] @@ -587,7 +618,9 @@ } ], "question": { - "en": "Made after {search}" + "en": "Made after {search}", + "de": "Erstellt nach {search}", + "es": "Realizado después de {search}" } } ] @@ -603,7 +636,9 @@ } ], "question": { - "en": "User language (iso-code) {search}" + "en": "User language (iso-code) {search}", + "de": "Benutzersprache (ISO-Code) {search}", + "es": "Idioma del usuario (código iso) {search}" } } ] @@ -619,7 +654,8 @@ } ], "question": { - "en": "Made with host {search}" + "en": "Made with host {search}", + "de": "Erstellt mit Host {search}" } } ] @@ -630,7 +666,8 @@ { "osmTags": "add-image>0", "question": { - "en": "Changeset added at least one image" + "en": "Changeset added at least one image", + "de": "Changeset hat mindestens ein Bild hinzugefügt" } } ] @@ -641,7 +678,8 @@ { "osmTags": "theme!=grb", "question": { - "en": "Exclude GRB theme" + "en": "Exclude GRB theme", + "de": "GRB-Thema ausschließen" } } ] @@ -652,7 +690,9 @@ { "osmTags": "theme!=etymology", "question": { - "en": "Exclude etymology theme" + "en": "Exclude etymology theme", + "de": "Etymologie-Thema ausschließen", + "es": "Excluir el tema de la etimología" } } ] @@ -667,7 +707,8 @@ { "id": "link_to_more", "render": { - "en": "More statistics can be found here" + "en": "More statistics can be found here", + "de": "Weitere Statistiken findest du hier" } }, { diff --git a/assets/themes/mapcomplete-changes/mapcomplete-changes.proto.json b/assets/themes/mapcomplete-changes/mapcomplete-changes.proto.json index 54b92aeaf4..cde6afad78 100644 --- a/assets/themes/mapcomplete-changes/mapcomplete-changes.proto.json +++ b/assets/themes/mapcomplete-changes/mapcomplete-changes.proto.json @@ -13,7 +13,6 @@ "de": "Diese Karte zeigt alle mit MapComplete vorgenommenen Änderungen", "es": "Este mapa muestra todos los cambios realizados con MapComplete", "pl": "Ta mapa pokazuje wszystkie zmiany wprowadzone za pomocą MapComplete" - }, "icon": "./assets/svg/logo.svg", "hideFromOverview": true, diff --git a/scripts/ScriptUtils.ts b/scripts/ScriptUtils.ts index 2db71de76d..7eb369a3a0 100644 --- a/scripts/ScriptUtils.ts +++ b/scripts/ScriptUtils.ts @@ -94,19 +94,28 @@ export default class ScriptUtils { }) } - public static getThemePaths(): string[] { - const blacklist = ["assets/themes/mapcomplete-changes/mapcomplete-changes.json"] + public static getThemePaths(useTranslationPaths = false): string[] { const normalFiles = ScriptUtils.readDirRecSync("./assets/themes") .filter((path) => path.endsWith(".json") && !path.endsWith(".proto.json")) .filter((path) => path.indexOf("license_info.json") < 0) - .filter(path => !blacklist.some(black => path.endsWith(black))) + + if (!useTranslationPaths) { + return normalFiles + } const specialfiles = ["./assets/themes/mapcomplete-changes/mapcomplete-changes.proto.json"] - return normalFiles.concat(specialfiles) + const blacklist = ["assets/themes/mapcomplete-changes/mapcomplete-changes.json"] + + const filtered = normalFiles.filter(path => !blacklist.some(black => path.endsWith(black))) + return filtered.concat(specialfiles) } - public static getThemeFiles(): { parsed: LayoutConfigJson; path: string; raw: string }[] { - return this.getThemePaths().map((path) => { + public static getThemeFiles(useTranslationPaths = false): { + parsed: LayoutConfigJson; + path: string; + raw: string + }[] { + return this.getThemePaths(useTranslationPaths).map((path) => { try { const contents = readFileSync(path, { encoding: "utf8" }) if (contents === "") { @@ -153,6 +162,7 @@ export default class ScriptUtils { const data = await ScriptUtils.Download(url, headers) return JSON.parse(data["content"]) } + public static async DownloadFetch( url: string, headers?: any @@ -163,6 +173,7 @@ export default class ScriptUtils { console.log("Fetched", url, data) return { content: data } } + public static Download( url: string, headers?: any @@ -198,17 +209,17 @@ export default class ScriptUtils { path: urlObj.pathname + urlObj.search, port: urlObj.port, - headers: headers, + headers: headers }, (res) => { const parts: string[] = [] res.setEncoding("utf8") - res.on("data", function (chunk) { + res.on("data", function(chunk) { // @ts-ignore parts.push(chunk) }) - res.addListener("end", function () { + res.addListener("end", function() { if (res.statusCode === 301 || res.statusCode === 302) { console.log("Got a redirect:", res.headers.location) resolve({ redirect: res.headers.location }) @@ -226,7 +237,7 @@ export default class ScriptUtils { }) } ) - request.on("error", function (e) { + request.on("error", function(e) { reject(e) }) } catch (e) { diff --git a/scripts/generateTranslations.ts b/scripts/generateTranslations.ts index 8521188c93..0bde6e9eea 100644 --- a/scripts/generateTranslations.ts +++ b/scripts/generateTranslations.ts @@ -670,7 +670,7 @@ function removeNonEnglishTranslations(object: any) { * Load the translations into the theme files */ function mergeThemeTranslations(englishOnly: boolean = false) { - const themeFiles = ScriptUtils.getThemeFiles() + const themeFiles = ScriptUtils.getThemeFiles(true) for (const themeFile of themeFiles) { let config = themeFile.parsed mergeLayerTranslation(config, themeFile.path, loadTranslationFilesFrom("themes")) @@ -723,7 +723,7 @@ class GenerateTranslations extends Script { { const l1 = generateTranslationsObjectFrom(ScriptUtils.getLayerFiles(), "layers") const l2 = generateTranslationsObjectFrom( - ScriptUtils.getThemeFiles().filter( + ScriptUtils.getThemeFiles(true).filter( (th) => th.parsed.mustHaveLanguage === undefined ), "themes"