Sync with new Compendium structure

This commit is contained in:
LeRatierBretonnien 2020-05-11 10:01:50 +02:00
parent 382ec09b1c
commit f75a8a0789
3 changed files with 18 additions and 15 deletions

View File

@ -53,7 +53,9 @@ Hooks.once('ready', () => {
const lang = game.settings.get('core', 'language'); const lang = game.settings.get('core', 'language');
if ( lang == "fr" ) { if ( lang == "fr" ) {
game.packs.forEach((pack, idx) => { let pack_array = [];
game.packs.forEach((pack, name) => {
let newpack = pack;
if(!pack.translated && pack.entity === 'Actor') { if(!pack.translated && pack.entity === 'Actor') {
let translations = { let translations = {
"label": pack.metadata.name, "label": pack.metadata.name,
@ -73,9 +75,10 @@ Hooks.once('ready', () => {
] ]
}; };
console.log("Actor compendium has been replaced !!!!"); 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 );
} }
} ); } );
}
} );

View File

@ -388,7 +388,7 @@ Hooks.once('init', () => {
special = " (" + game.i18n.localize( res[2].trim() ) + ")"; // And the special keyword special = " (" + game.i18n.localize( res[2].trim() ) + ")"; // And the special keyword
} }
var trait_fr = fulltraits.translate( { name: name_en } ); 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; trait_en.name = nbt + trait_fr.name + special;
if ( trait_fr.data && trait_fr.data.description && trait_fr.data.description.value ) { if ( trait_fr.data && trait_fr.data.description && trait_fr.data.description.value ) {
trait_en.data.description.value = 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 special = " (" + game.i18n.localize( res[2].trim() ) + ")"; // And the special keyword
} }
var trait_fr = fullskills.translate( { name: name_en } ); 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.name = trait_fr.name + special;
trait_en.data.description.value = trait_fr.data.description.value; 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 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 } ); 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; trait_en.name = trait_fr.name + special;
if ( trait_fr.data && trait_fr.data.description && trait_fr.data.description.value ) if ( trait_fr.data && trait_fr.data.description && trait_fr.data.description.value )
trait_en.data.description.value = 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 special = " (" + game.i18n.localize( res[2].trim() ) + ")"; // And the special keyword
} }
var trait_fr = fulltalents.translate( { name: name_en } ); 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.name = trait_fr.name + special;
trait_en.data.description.value = trait_fr.data.description.value; trait_en.data.description.value = trait_fr.data.description.value;
} else if ( trait_en.type == "career") { } else if ( trait_en.type == "career") {
var career_fr = fullcareers.translate( trait_en ); 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; 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") { } 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 ); 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.name = trapping_fr.name;
trait_en.data.description = trapping_fr.data.description; trait_en.data.description = trapping_fr.data.description;
} }

View File

@ -2,9 +2,9 @@
"name": "WH4-fr-translation", "name": "WH4-fr-translation",
"title": "Traduction du module WH4 en Français.", "title": "Traduction du module WH4 en Français.",
"description": "La traduction du module WH4.", "description": "La traduction du module WH4.",
"version": "0.69", "version": "0.70",
"minimumCoreVersion" : "0.5.1", "minimumCoreVersion" : "0.5.5",
"compatibleCoreVersion": "0.5.5", "compatibleCoreVersion": "0.5.6",
"author": "LeRatierBretonnien", "author": "LeRatierBretonnien",
"esmodules": [ "esmodules": [
"babele-register.js", "babele-register.js",