From f75a8a07892c68379856891a11d152a9b5234138 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Mon, 11 May 2020 10:01:50 +0200 Subject: [PATCH] Sync with new Compendium structure --- addon-register.js | 15 +++++++++------ babele-register.js | 12 ++++++------ module.json | 6 +++--- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/addon-register.js b/addon-register.js index 460a49b..e15ea7d 100644 --- a/addon-register.js +++ b/addon-register.js @@ -52,9 +52,11 @@ Hooks.on("chatMessage", (html, content, msg) => { Hooks.once('ready', () => { const lang = game.settings.get('core', 'language'); - if ( lang == "fr" ) { - game.packs.forEach((pack, idx) => { - if(!pack.translated && pack.entity === 'Actor') { + if ( lang == "fr" ) { + let pack_array = []; + game.packs.forEach((pack, name) => { + let newpack = pack; + if(!pack.translated && pack.entity === 'Actor') { let translations = { "label": pack.metadata.name, "mapping": { @@ -71,11 +73,12 @@ Hooks.once('ready', () => { }, "entries": [ ] - }; + }; console.log("Actor compendium has been replaced !!!!"); - game.packs[idx] = new TranslatedCompendium(pack, translations); + newpack = new TranslatedCompendium(pack, translations); } + pack_array.push( [name, newpack ] ); } ); + game.packs = new Collection( pack_array ); } - } ); diff --git a/babele-register.js b/babele-register.js index e220d7c..72bc4fb 100644 --- a/babele-register.js +++ b/babele-register.js @@ -388,7 +388,7 @@ Hooks.once('init', () => { special = " (" + game.i18n.localize( res[2].trim() ) + ")"; // And the special keyword } var trait_fr = fulltraits.translate( { name: name_en } ); - console.log(">>>>> Trait ?", name_en, nbt, trait_fr.name, special); + //console.log(">>>>> Trait ?", name_en, nbt, trait_fr.name, special); trait_en.name = nbt + trait_fr.name + special; if ( trait_fr.data && trait_fr.data.description && trait_fr.data.description.value ) { trait_en.data.description.value = trait_fr.data.description.value; @@ -410,7 +410,7 @@ Hooks.once('init', () => { special = " (" + game.i18n.localize( res[2].trim() ) + ")"; // And the special keyword } var trait_fr = fullskills.translate( { name: name_en } ); - console.log(">>>>> Skill ?", name_en, special, trait_fr.name); + //console.log(">>>>> Skill ?", name_en, special, trait_fr.name); trait_en.name = trait_fr.name + special; trait_en.data.description.value = trait_fr.data.description.value; @@ -419,7 +419,7 @@ Hooks.once('init', () => { if ( (!trait_fr.data || !trait_fr.data.description || !trait_fr.data.description.value) && eisspells) { // If no translation, test eisspells trait_fr = eisspells.translate( { name: name_en } ); } - console.log(">>>>> Spell ?", name_en, special, trait_fr.name ); + //console.log(">>>>> Spell ?", name_en, special, trait_fr.name ); trait_en.name = trait_fr.name + special; if ( trait_fr.data && trait_fr.data.description && trait_fr.data.description.value ) trait_en.data.description.value = trait_fr.data.description.value; @@ -431,16 +431,16 @@ Hooks.once('init', () => { special = " (" + game.i18n.localize( res[2].trim() ) + ")"; // And the special keyword } var trait_fr = fulltalents.translate( { name: name_en } ); - console.log(">>>>> Talent ?", name_en, special, trait_fr.name); + //console.log(">>>>> Talent ?", name_en, special, trait_fr.name); trait_en.name = trait_fr.name + special; trait_en.data.description.value = trait_fr.data.description.value; } else if ( trait_en.type == "career") { var career_fr = fullcareers.translate( trait_en ); - console.log(">>>>> Career ?", name_en, career_fr.name); + //console.log(">>>>> Career ?", name_en, career_fr.name); trait_en = career_fr; } else if ( trait_en.type == "trapping" || trait_en.type == "weapon" || trait_en.type == "armour" || trait_en.type == "container" || trait_en.type == "money") { var trapping_fr = fulltrappings.translate( trait_en ); - console.log(">>>>> Trapping ?", name_en, trapping_fr.name); + //console.log(">>>>> Trapping ?", name_en, trapping_fr.name); trait_en.name = trapping_fr.name; trait_en.data.description = trapping_fr.data.description; } diff --git a/module.json b/module.json index f501490..2780a7f 100644 --- a/module.json +++ b/module.json @@ -2,9 +2,9 @@ "name": "WH4-fr-translation", "title": "Traduction du module WH4 en Français.", "description": "La traduction du module WH4.", - "version": "0.69", - "minimumCoreVersion" : "0.5.1", - "compatibleCoreVersion": "0.5.5", + "version": "0.70", + "minimumCoreVersion" : "0.5.5", + "compatibleCoreVersion": "0.5.6", "author": "LeRatierBretonnien", "esmodules": [ "babele-register.js",