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;