fix: Karrieregruppe und Ausrüstungs-Übersetzung live gegen Foundry 14 + Babele 2.9.1 verifiziert

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 <noreply@anthropic.com>
This commit is contained in:
alzer
2026-09-28 13:19:33 +02:00
co-authored by Claude Sonnet 5
parent e10f210bec
commit 490403d958
11 changed files with 24 additions and 11 deletions
+1 -1
View File
@@ -18182,6 +18182,6 @@
"path": "system.talents" "path": "system.talents"
}, },
"tests": "system.tests.value", "tests": "system.tests.value",
"trappings": "system.trappings" "trappings": { "converter": "static_array", "path": "system.trappings" }
} }
} }
+1 -1
View File
@@ -33,7 +33,7 @@
"path": "system.damage.value", "path": "system.damage.value",
"converter": "spells_duration_range_target_damage" "converter": "spells_duration_range_target_damage"
}, },
"trappings": "system.trappings", "trappings": { "converter": "static_array", "path": "system.trappings" },
"gmdescription": "system.gmdescription.value", "gmdescription": "system.gmdescription.value",
"durationValue": "system.duration.value", "durationValue": "system.duration.value",
"durationUnit": "system.duration.unit", "durationUnit": "system.duration.unit",
+1 -1
View File
@@ -799,6 +799,6 @@
"converter": "career_talents", "converter": "career_talents",
"path": "system.talents" "path": "system.talents"
}, },
"trappings": "system.trappings" "trappings": { "converter": "static_array", "path": "system.trappings" }
} }
} }
+1 -1
View File
@@ -8,7 +8,7 @@
}, },
"mapping": { "mapping": {
"description": "system.description.value", "description": "system.description.value",
"trappings": "system.trappings", "trappings": { "converter": "static_array", "path": "system.trappings" },
"class": { "class": {
"path": "system.class.value", "path": "system.class.value",
"converter": "generic_localization" "converter": "generic_localization"
+1 -1
View File
@@ -14,7 +14,7 @@
}, },
"mapping": { "mapping": {
"description": "system.description.value", "description": "system.description.value",
"trappings": "system.trappings", "trappings": { "converter": "static_array", "path": "system.trappings" },
"class": { "class": {
"path": "system.class.value", "path": "system.class.value",
"converter": "generic_localization" "converter": "generic_localization"
+1 -1
View File
@@ -84,6 +84,6 @@
"path": "system.talents" "path": "system.talents"
}, },
"tests": "system.tests.value", "tests": "system.tests.value",
"trappings": "system.trappings" "trappings": { "converter": "static_array", "path": "system.trappings" }
} }
} }
+1 -1
View File
@@ -12,7 +12,7 @@
}, },
"mapping": { "mapping": {
"description": "system.description.value", "description": "system.description.value",
"trappings": "system.trappings", "trappings": { "converter": "static_array", "path": "system.trappings" },
"class": { "class": {
"path": "system.class.value", "path": "system.class.value",
"converter": "generic_localization" "converter": "generic_localization"
+1 -1
View File
@@ -24,7 +24,7 @@
"converter": "generic_localization" "converter": "generic_localization"
}, },
"career_careergroup": "system.careergroup.value", "career_careergroup": "system.careergroup.value",
"trappings": "system.trappings" "trappings": { "converter": "static_array", "path": "system.trappings" }
}, },
"entries": { "entries": {
"Ahlspiess": { "Ahlspiess": {
+1 -1
View File
@@ -9,7 +9,7 @@
}, },
"mapping": { "mapping": {
"description": "system.description.value", "description": "system.description.value",
"trappings": "system.trappings", "trappings": { "converter": "static_array", "path": "system.trappings" },
"class": { "class": {
"path": "system.class.value", "path": "system.class.value",
"converter": "generic_localization" "converter": "generic_localization"
+1 -1
View File
@@ -8,7 +8,7 @@
} }
], ],
"url": "https://gitea.palmenalzer.de/alzer/wfrp-4e-de", "url": "https://gitea.palmenalzer.de/alzer/wfrp-4e-de",
"version": "8.7.05", "version": "8.7.06",
"esmodules": [ "esmodules": [
"modules/babele-register.js", "modules/babele-register.js",
"modules/addon-register.js", "modules/addon-register.js",
+14 -1
View File
@@ -207,9 +207,13 @@ Hooks.once('babele.init', () => {
// before giving up - a career group's defining career may only exist in one of them, // 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 // 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). // 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) { for (let compData of validCompendiums) {
let newName = game.babele.translate(compData.metadata.id, { name: value })?.name; 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 }); ui.notifications.error("Das Übersetzen der Karriere " + value + " ist nicht möglich. Sie ist wahrscheinlich nicht übersetzt.", { permanent: true });
return value; 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) // 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, "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 :) "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); //console.log("Parsing mutation :", value);
if (!value) return; if (!value) return;