From 490403d95819e3bcc8314a6d3aa216dbf7587a69 Mon Sep 17 00:00:00 2001 From: alzer <> Date: Mon, 28 Sep 2026 13:19:33 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Karrieregruppe=20und=20Ausr=C3=BCstungs-?= =?UTF-8?q?=C3=9Cbersetzung=20live=20gegen=20Foundry=2014=20+=20Babele=202?= =?UTF-8?q?.9.1=20verifiziert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Live-Debugging mit Playwright gegen eine frisch installierte Foundry- Instanz (Version 14.368, Babele 2.9.1) ergab zwei tatsächliche, voneinander unabhängige Ursachen für das seit mehreren Commits gemeldete "Karrieregruppe zeigt noch 'Spy'"-Problem: 1. career_careergroup_fn (babele-register.js): game.babele.translate() gibt bei fehlendem Treffer in Babele 2.9.1 das übergebene Stub- Objekt unverändert zurück (nie null/undefined). Die vorherige Korrektur (Commit 19908b5) prüfte nur auf einen Wahrheitswert, der aber auch beim Fehlschlag immer erfüllt ist - dadurch gewann praktisch immer das erste career-getaggte Pack (wfrp4e-archives1 kommt alphabetisch vor wfrp4e-core), selbst wenn dort kein Treffer vorlag. Jetzt wird zusätzlich geprüft, ob sich der Name gegenüber dem Original tatsächlich geändert hat. 2. NEU entdeckt: Babele 2.9+ hat PrimitiveConverter (zuständig für einfache String-Pfad-Mappings ohne Converter) so geändert, dass Array-/Objekt-Werte als "structural" abgelehnt und die Übersetzung für das Feld stillschweigend übersprungen wird. Das betraf "trappings" (Karriereausrüstung, ein String-Array) in allen 9 *.items.json-Dateien mit Karrieren - unabhängig vom careergroup-Bug und unabhängig von unseren Übersetzungsdaten, die die ganze Zeit korrekt waren. Fix: "trappings" von einem reinen String-Pfad auf einen Converter-Mapping-Eintrag (neuer "static_array"-Converter) umgestellt, der die PrimitiveConverter-Prüfung umgeht. Beide Fixes wurden live in der laufenden Foundry-Instanz nachgestellt und nach dem Fix verifiziert (Meisterspion: careergroup "Spion", trappings korrekt deutsch) bevor sie committet wurden. Co-Authored-By: Claude Sonnet 5 --- compendium/wfrp4e-core.items.json | 2 +- compendium/wfrp4e-dotr.dotr-items.json | 2 +- compendium/wfrp4e-eis.items.json | 2 +- compendium/wfrp4e-lustria.items.json | 2 +- compendium/wfrp4e-owb2.items.json | 2 +- compendium/wfrp4e-salzenmund.items.json | 2 +- compendium/wfrp4e-soc.items.json | 2 +- compendium/wfrp4e-up-in-arms.items.json | 2 +- compendium/wfrp4e-zoo.items.json | 2 +- module.json | 2 +- modules/babele-register.js | 15 ++++++++++++++- 11 files changed, 24 insertions(+), 11 deletions(-) diff --git a/compendium/wfrp4e-core.items.json b/compendium/wfrp4e-core.items.json index 577fa8c..c214717 100644 --- a/compendium/wfrp4e-core.items.json +++ b/compendium/wfrp4e-core.items.json @@ -18182,6 +18182,6 @@ "path": "system.talents" }, "tests": "system.tests.value", - "trappings": "system.trappings" + "trappings": { "converter": "static_array", "path": "system.trappings" } } } diff --git a/compendium/wfrp4e-dotr.dotr-items.json b/compendium/wfrp4e-dotr.dotr-items.json index 5cb3626..d59f757 100644 --- a/compendium/wfrp4e-dotr.dotr-items.json +++ b/compendium/wfrp4e-dotr.dotr-items.json @@ -33,7 +33,7 @@ "path": "system.damage.value", "converter": "spells_duration_range_target_damage" }, - "trappings": "system.trappings", + "trappings": { "converter": "static_array", "path": "system.trappings" }, "gmdescription": "system.gmdescription.value", "durationValue": "system.duration.value", "durationUnit": "system.duration.unit", diff --git a/compendium/wfrp4e-eis.items.json b/compendium/wfrp4e-eis.items.json index b793c6c..94980d8 100644 --- a/compendium/wfrp4e-eis.items.json +++ b/compendium/wfrp4e-eis.items.json @@ -799,6 +799,6 @@ "converter": "career_talents", "path": "system.talents" }, - "trappings": "system.trappings" + "trappings": { "converter": "static_array", "path": "system.trappings" } } } diff --git a/compendium/wfrp4e-lustria.items.json b/compendium/wfrp4e-lustria.items.json index 884d3a5..bb4e6e5 100644 --- a/compendium/wfrp4e-lustria.items.json +++ b/compendium/wfrp4e-lustria.items.json @@ -8,7 +8,7 @@ }, "mapping": { "description": "system.description.value", - "trappings": "system.trappings", + "trappings": { "converter": "static_array", "path": "system.trappings" }, "class": { "path": "system.class.value", "converter": "generic_localization" diff --git a/compendium/wfrp4e-owb2.items.json b/compendium/wfrp4e-owb2.items.json index ae44e21..0f5fbea 100644 --- a/compendium/wfrp4e-owb2.items.json +++ b/compendium/wfrp4e-owb2.items.json @@ -14,7 +14,7 @@ }, "mapping": { "description": "system.description.value", - "trappings": "system.trappings", + "trappings": { "converter": "static_array", "path": "system.trappings" }, "class": { "path": "system.class.value", "converter": "generic_localization" diff --git a/compendium/wfrp4e-salzenmund.items.json b/compendium/wfrp4e-salzenmund.items.json index 3606797..e4eb3a7 100644 --- a/compendium/wfrp4e-salzenmund.items.json +++ b/compendium/wfrp4e-salzenmund.items.json @@ -84,6 +84,6 @@ "path": "system.talents" }, "tests": "system.tests.value", - "trappings": "system.trappings" + "trappings": { "converter": "static_array", "path": "system.trappings" } } } \ No newline at end of file diff --git a/compendium/wfrp4e-soc.items.json b/compendium/wfrp4e-soc.items.json index 19ed014..2a936b4 100644 --- a/compendium/wfrp4e-soc.items.json +++ b/compendium/wfrp4e-soc.items.json @@ -12,7 +12,7 @@ }, "mapping": { "description": "system.description.value", - "trappings": "system.trappings", + "trappings": { "converter": "static_array", "path": "system.trappings" }, "class": { "path": "system.class.value", "converter": "generic_localization" diff --git a/compendium/wfrp4e-up-in-arms.items.json b/compendium/wfrp4e-up-in-arms.items.json index 5def893..a4867d3 100644 --- a/compendium/wfrp4e-up-in-arms.items.json +++ b/compendium/wfrp4e-up-in-arms.items.json @@ -24,7 +24,7 @@ "converter": "generic_localization" }, "career_careergroup": "system.careergroup.value", - "trappings": "system.trappings" + "trappings": { "converter": "static_array", "path": "system.trappings" } }, "entries": { "Ahlspiess": { diff --git a/compendium/wfrp4e-zoo.items.json b/compendium/wfrp4e-zoo.items.json index 1b71cde..d330c39 100644 --- a/compendium/wfrp4e-zoo.items.json +++ b/compendium/wfrp4e-zoo.items.json @@ -9,7 +9,7 @@ }, "mapping": { "description": "system.description.value", - "trappings": "system.trappings", + "trappings": { "converter": "static_array", "path": "system.trappings" }, "class": { "path": "system.class.value", "converter": "generic_localization" diff --git a/module.json b/module.json index 17fd9f3..b67bf0b 100644 --- a/module.json +++ b/module.json @@ -8,7 +8,7 @@ } ], "url": "https://gitea.palmenalzer.de/alzer/wfrp-4e-de", - "version": "8.7.05", + "version": "8.7.06", "esmodules": [ "modules/babele-register.js", "modules/addon-register.js", diff --git a/modules/babele-register.js b/modules/babele-register.js index d5e9851..3e6127d 100644 --- a/modules/babele-register.js +++ b/modules/babele-register.js @@ -207,9 +207,13 @@ Hooks.once('babele.init', () => { // before giving up - a career group's defining career may only exist in one of them, // so returning after the first pack silently left it untranslated whenever that pack // happened not to be the one with the match (e.g. "Spy" only exists in wfrp4e-core). + // IMPORTANT: game.babele.translate() returns the ORIGINAL stub object unchanged when a + // pack has no matching dictionary entry - it never returns null/undefined - so `newName` + // is truthy even on a miss (it's just `value` again). Must compare against `value` to + // detect an actual match, otherwise the very first pack always "wins" by default. for (let compData of validCompendiums) { let newName = game.babele.translate(compData.metadata.id, { name: value })?.name; - if (newName) return newName; + if (newName && newName !== value) return newName; } ui.notifications.error("Das Übersetzen der Karriere " + value + " ist nicht möglich. Sie ist wahrscheinlich nicht übersetzt.", { permanent: true }); return value; @@ -579,6 +583,15 @@ Hooks.once('babele.init', () => { // Search back in careers the translated name of the groupe (as it is the name of the level career itself) "career_careergroup": career_careergroup_fn, + // Babele 2.9+'s PrimitiveConverter (used for plain string-path mappings) rejects any + // translation whose value is an array/object as "structural" and silently skips the + // field, leaving the English original in place - this broke "trappings" (an array of + // strings) across every *.items.json career pack once Babele was updated past 2.6.x. + // Routing it through a converter instead sidesteps that check entirely. Converters get + // called as (originalValue, translation, ...) - we want the dictionary's own translated + // array, not the original English one, so we return the 2nd argument, not the 1st. + "static_array": (value, translation) => translation, + "mutations_modifier": (value) => { // This is really UGLYYYY i know, but i started like this and discovered afterward that many strings were not easy to automate... Sorry :) //console.log("Parsing mutation :", value); if (!value) return;