forked from public/foundryvtt-wh4-lang-fr-fr
		
	Auto-translate spells + parse eis items
This commit is contained in:
		| @@ -360,6 +360,9 @@ Hooks.once('init', () => { | ||||
|         var fulltalents = game.packs.find(p => p.collection === 'wfrp4e.talents');         | ||||
|         var fullcareers = game.packs.find(p => p.collection === 'wfrp4e.careers'); | ||||
|         var fulltrappings = game.packs.find(p => p.collection === 'wfrp4e.trappings'); | ||||
|         var fullspells    = game.packs.find(p => p.collection === 'wfrp4e.spells'); | ||||
|         var eisitems      = game.packs.find(p => p.collection === 'eis.eisitems');       | ||||
|         var eisspells     = game.packs.find(p => p.collection === 'eis.eisspells');       | ||||
|          | ||||
|         for (let trait_en of beast_traits) | ||||
|         {  | ||||
| @@ -371,6 +374,7 @@ Hooks.once('init', () => { | ||||
|             if ( name_en.includes("Tentacles") ) { // Process specific Tentacles case | ||||
|               var re  = /(.d*)x Tentacles/i; | ||||
|               var res = re.exec( name_en ); | ||||
|               if ( res && res[1] )  | ||||
|                 nbt = res[1] + "x "; | ||||
|               name_en = "Tentacles"; | ||||
|             } else if ( name_en.includes("(") && name_en.includes(")") ) { // Then process specific traits name with (xxxx) inside | ||||
| @@ -382,8 +386,14 @@ Hooks.once('init', () => { | ||||
|             var trait_fr = fulltraits.translate( { name: name_en } ); | ||||
|             console.log(">>>>> Trait ?", name_en, nbt, trait_fr.name, special); | ||||
|             trait_en.name = nbt + trait_fr.name + special; | ||||
|             if ( trait_en.data.description && trait_en.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; | ||||
|             } else if ( eisitems ) { // No description in the FR compendium -> test other compendium if presenr | ||||
|               trait_fr = eisitems.translate( { name: name_en } ); | ||||
|               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;               | ||||
|             } | ||||
|             if ( isNaN(trait_en.data.specification.value) ) { // This is a string, so translate it | ||||
|               //console.log("Translating : ", trait_en.data.specification.value);             | ||||
|               trait_en.data.specification.value = game.i18n.localize( trait_en.data.specification.value.trim() );             | ||||
| @@ -400,7 +410,15 @@ Hooks.once('init', () => { | ||||
|             trait_en.name = trait_fr.name + special; | ||||
|             trait_en.data.description.value = trait_fr.data.description.value;             | ||||
|            | ||||
|              | ||||
|           } else if ( trait_en.type == "spell") { | ||||
|             var trait_fr = fullspells.translate( { name: name_en } ); | ||||
|             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 ); | ||||
|             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;                           | ||||
|           } else if ( trait_en.type == "talent") { | ||||
|             if ( name_en.includes("(") && name_en.includes(")") ) { // Then process specific skills name with (xxxx) inside | ||||
|                 var re  = /(.*) +\((.*)\)/i; | ||||
|   | ||||
| @@ -1,6 +0,0 @@ | ||||
| { | ||||
|     "label": "Ennemi Intérieur", | ||||
|     "entries": [ | ||||
|         { "id": "Reinhardt", "name": "Reinhardt", "bio": "Un Bon gars !"} | ||||
|     ] | ||||
| }     | ||||
| @@ -2,7 +2,7 @@ | ||||
|   "name": "WH4-fr-translation", | ||||
|   "title": "Traduction du module WH4 en Français.", | ||||
|   "description": "La traduction du module WH4.", | ||||
|   "version": "0.63", | ||||
|   "version": "0.64", | ||||
|   "minimumCoreVersion" : "0.5.1", | ||||
|   "compatibleCoreVersion": "0.5.5", | ||||
|   "author": "LeRatierBretonnien", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user