From 0650e390193d4c1b881b6283bcb324c27c6bb316 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Sat, 16 Sep 2023 15:27:37 +0200 Subject: [PATCH] Fix trait translation --- babele-register.js | 53 ++++++++++++----------- module.json | 105 +++++++++++++++++++++++++++++---------------- 2 files changed, 98 insertions(+), 60 deletions(-) diff --git a/babele-register.js b/babele-register.js index b97929e..ab80c40 100644 --- a/babele-register.js +++ b/babele-register.js @@ -152,7 +152,7 @@ Hooks.once('init', () => { let compendiumName = 'wfrp4e-core.skills' // Per default if (game.system.version.match("7.")) { compendiumName = 'wfrp4e-core.items' - } + } //console.log( "Thru here ...", compendium, skills_list); if (skills_list) { let i; @@ -198,13 +198,13 @@ Hooks.once('init', () => { return results } // Auto patch - if (results[0].text.includes("wfrp4e-core.career-descriptions") ) { + if (results[0].text.includes("wfrp4e-core.career-descriptions")) { if (game.system.version.match("7.")) { results[0].text = "wfrp4e-core.journals" } else { - results[0].text = "wfrp4e-core.journal-entries" + results[0].text = "wfrp4e-core.journal-entries" } - } + } if (results[0].text.includes("wfrp4e-core.journal")) { for (let data of results) { let career = data.text.match(/{(.*)}/) @@ -237,7 +237,7 @@ Hooks.once('init', () => { let compendiumName = 'wfrp4e-core.talents' // Per default if (game.system.version.match("7.")) { compendiumName = 'wfrp4e-core.items' - } + } let i; if (talents_list) { let len = talents_list.length; @@ -261,7 +261,7 @@ Hooks.once('init', () => { if (res2) { transl = res2[1] + " (" + subword + ")"; } else { - transl = translw + transl = translw } } } @@ -316,18 +316,23 @@ Hooks.once('init', () => { let compendiumName = 'wfrp4e-core.traits' // Per default if (game.system.version.match("7.")) { compendiumName = 'wfrp4e-core.items' - } + } let trait_fr = game.babele.translate(compendiumName, { name: name_en }, true); //console.log(">>>>> Trait ?", name_en, nbt, trait_fr, trait_fr.name, special); - trait_fr.name = trait_fr.name || trait_en.name - trait_en.name = nbt + trait_fr.name + special; + if (trait_fr?.name) { + trait_fr.name = trait_fr.name || trait_en.name + trait_en.name = nbt + trait_fr.name + special; + } if (trait_fr.system?.description?.value) { trait_en.system.description.value = trait_fr.system.description.value; } else if (game.modules.get('wfrp4e-eis')) { // No description in the FR compendium -> test other compendium if presenr trait_fr = game.babele.translate('wfrp4e-eis.items', { name: name_en }, true); - trait_en.name = nbt + trait_fr.name + special; - if (trait_fr.system?.description?.value) - trait_en.system.description.value = trait_fr.system.description.value; + if (trait_fr?.name) { + trait_en.name = nbt + trait_fr.name + special + } + if (trait_fr.system?.description?.value) { + trait_en.system.description.value = trait_fr.system.description.value + } } if (trait_en.system?.specification && isNaN(trait_en.system.specification.value)) { // This is a string, so translate it //console.log("Translating : ", trait_en.system.specification.value); @@ -343,7 +348,7 @@ Hooks.once('init', () => { let compendiumSkills = 'wfrp4e-core.skills' // Per default if (game.system.version.match("7.")) { compendiumSkills = 'wfrp4e-core.items' - } + } let trait_fr = game.babele.translate(compendiumSkills, { name: name_en }, true); //console.log(">>>>> Skill ?", name_en, special, trait_fr.name, trait_fr); trait_fr.name = trait_fr.name || name_en @@ -358,7 +363,7 @@ Hooks.once('init', () => { let compendiumPrayers = 'wfrp4e-core.prayers' // Per default if (game.system.version.match("7.")) { compendiumPrayers = 'wfrp4e-core.items' - } + } let trait_fr = game.babele.translate(compendiumPrayers, { name: name_en }, true); //console.log(">>>>> Prayer ?", name_en, special, trait_fr.name ); trait_fr.name = trait_fr.name || name_en @@ -370,7 +375,7 @@ Hooks.once('init', () => { let compendiumSpells = 'wfrp4e-core.spells' // Per default if (game.system.version.match("7.")) { compendiumSpells = 'wfrp4e-core.items' - } + } let trait_fr = game.babele.translate(compendiumSpells, { name: name_en }, true) if (trait_fr.name == name_en) { // If no translation, test eisspells trait_fr = game.babele.translate('wfrp4e-eis.eisspells', { name: name_en }, true); @@ -383,8 +388,8 @@ Hooks.once('init', () => { trait_en.name = trait_fr.name + special; if (trait_fr.system?.description?.value) trait_en.system.description.value = trait_fr.system.description.value; - - } else if (trait_en.type == "talent") { + + } else if (trait_en.type == "talent") { if (name_en.includes("(") && name_en.includes(")")) { // Then process specific skills name with (xxxx) inside let re = /(.*) +\((.*)\)/i; let res = re.exec(name_en); @@ -394,7 +399,7 @@ Hooks.once('init', () => { let compendiumTalents = 'wfrp4e-core.talents' // Per default if (game.system.version.match("7.")) { compendiumTalents = 'wfrp4e-core.items' - } + } let trait_fr = game.babele.translate(compendiumTalents, { name: name_en }, true) trait_fr.name = trait_fr.name || name_en // Security since babele v10 //console.log(">>>>> Talent ?", trait_fr, name_en, special, trait_fr.name); @@ -412,11 +417,11 @@ Hooks.once('init', () => { let compendiumCareers = 'wfrp4e-core.careers' // Per default if (game.system.version.match("7.")) { compendiumCareers = 'wfrp4e-core.items' - } + } let career_fr = game.babele.translate(compendiumCareers, { name: name_en }, true); trait_en.name = career_fr.name || trait_en.name //console.log(">>>>> Career ?", career_fr.name ); - if ( career_fr?.system) { + if (career_fr?.system) { trait_en.system = duplicate(career_fr.system); } @@ -424,8 +429,8 @@ Hooks.once('init', () => { let compendiumTrappings = 'wfrp4e-core.trappings' // Per default if (game.system.version.match("7.")) { compendiumTrappings = 'wfrp4e-core.items' - } - let trapping_fr = game.babele.translate(compendiumTrappings, { name: name_en }, true); + } + let trapping_fr = game.babele.translate(compendiumTrappings, { name: name_en }, true); //console.log(">>>>> Trapping ?", name_en, trapping_fr.name); trait_en.name = trapping_fr.name || trait_en.name if (trapping_fr.system?.description?.value) { @@ -484,7 +489,7 @@ Hooks.once('init', () => { let compendiumCareers = 'wfrp4e-core.careers' // Per default if (game.system.version.match("7.")) { compendiumCareers = 'wfrp4e-core.items' - } + } let compendium = game.packs.find(p => p.collection === compendiumCareers); if (compendium) { let newName = game.babele.translate(compendiumCareers, { name: value }).name @@ -622,7 +627,7 @@ function registerUsageCount(registerKey) { /*---------------------------------------------------------------------*/ Hooks.once('ready', () => { - + registerUsageCount("wh4-fr-translation") diff --git a/module.json b/module.json index d7dabf4..0d5919c 100644 --- a/module.json +++ b/module.json @@ -8,7 +8,7 @@ } ], "url": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr", - "version": "7.0.8", + "version": "7.0.9", "esmodules": [ "babele-register.js", "addon-register.js", @@ -30,107 +30,140 @@ "label": "Plats d'Auberges", "type": "RollTable", "name": "plats-dauberges", - "path": "packs/plats-dauberges.db", + "path": "packs/plats-dauberges", "system": "wfrp4e", - "private": false, - "flags": {} + "flags": {}, + "ownership": { + "PLAYER": "OBSERVER", + "ASSISTANT": "OWNER" + } }, { "label": "Dons de Rhya", "type": "JournalEntry", "name": "dons-de-rhya", - "path": "packs/dons-de-rhya.db", + "path": "packs/dons-de-rhya", "system": "wfrp4e", - "private": false, - "flags": {} + "flags": {}, + "ownership": { + "PLAYER": "OBSERVER", + "ASSISTANT": "OWNER" + } }, { "label": "Sorts FR", "type": "Item", "name": "sort-fr", - "path": "packs/sort-fr.db", + "path": "packs/sort-fr", "system": "wfrp4e", - "private": false, - "flags": {} + "flags": {}, + "ownership": { + "PLAYER": "OBSERVER", + "ASSISTANT": "OWNER" + } }, { "label": "Aides de Jeu FR", "type": "JournalEntry", "name": "aides-de-jeu-fr", - "path": "packs/aides-de-jeu-fr.db", + "path": "packs/aides-de-jeu-fr", "system": "wfrp4e", - "private": false, - "flags": {} + "flags": {}, + "ownership": { + "PLAYER": "OBSERVER", + "ASSISTANT": "OWNER" + } }, { "label": "Potions : Drogues et Sédatifs", "type": "Item", "name": "drogues-and-sedatifs", - "path": "packs/drogues-and-sedatifs.db", + "path": "packs/drogues-and-sedatifs", "system": "wfrp4e", - "private": false, - "flags": {} + "flags": {}, + "ownership": { + "PLAYER": "OBSERVER", + "ASSISTANT": "OWNER" + } }, { "label": "Potions : Pansements et Cataplasmes", "type": "Item", "name": "pansements-and-cataplasmes", - "path": "packs/pansements-and-cataplasmes.db", + "path": "packs/pansements-and-cataplasmes", "system": "wfrp4e", - "private": false, - "flags": {} + "flags": {}, + "ownership": { + "PLAYER": "OBSERVER", + "ASSISTANT": "OWNER" + } }, { "label": "Potions : Poisons et Toxiques", "type": "Item", "name": "poisons-and-toxiques", - "path": "packs/poisons-and-toxiques.db", + "path": "packs/poisons-and-toxiques", "system": "wfrp4e", - "private": false, - "flags": {} + "flags": {}, + "ownership": { + "PLAYER": "OBSERVER", + "ASSISTANT": "OWNER" + } }, { "label": "Potions : Potions et Décoctions", "type": "Item", "name": "potions-and-decoctions", - "path": "packs/potions-and-decoctions.db", + "path": "packs/potions-and-decoctions", "system": "wfrp4e", - "private": false, - "flags": {} + "flags": {}, + "ownership": { + "PLAYER": "OBSERVER", + "ASSISTANT": "OWNER" + } }, { "label": "Potions : Antidotes et Remèdes", "type": "Item", "name": "antidotes-and-remedes", - "path": "packs/antidotes-and-remedes.db", + "path": "packs/antidotes-and-remedes", "system": "wfrp4e", - "private": false, - "flags": {} + "flags": {}, + "ownership": { + "PLAYER": "OBSERVER", + "ASSISTANT": "OWNER" + } }, { "label": "Tables des Traductions", "type": "JournalEntry", "name": "tables-des-traductions", - "path": "packs/tables-des-traductions.db", + "path": "packs/tables-des-traductions", "system": "wfrp4e", - "private": false, - "flags": {} + "flags": {}, + "ownership": { + "PLAYER": "OBSERVER", + "ASSISTANT": "OWNER" + } }, { "label": "Apothicarium", "type": "JournalEntry", "name": "apothicarium", - "path": "packs/apothicarium.db", + "path": "packs/apothicarium", "system": "wfrp4e", - "private": false, - "flags": {} + "flags": {}, + "ownership": { + "PLAYER": "OBSERVER", + "ASSISTANT": "OWNER" + } } ], "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/raw/v10/module.json", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/archive/foundryvtt-wh4-lang-fr-7.0.8.zip", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/archive/foundryvtt-wh4-lang-fr-7.0.9.zip", "id": "wh4-fr-translation", "compatibility": { - "minimum": "11", + "minimum": "10", "verified": "11" }, "relationships": {