From f916c14848049a647fc40c4a89c64337185818e1 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Fri, 30 Sep 2022 20:56:12 +0200 Subject: [PATCH] Fix Traits translation --- addon-register.js | 10 +++--- babele-register.js | 39 +++++++++++---------- compendium/wfrp4e-core.journal-entries.json | 7 +++- module.json | 4 +-- modules/import-stat-2.js | 20 +++++------ 5 files changed, 43 insertions(+), 37 deletions(-) diff --git a/addon-register.js b/addon-register.js index d2876c6..08ca4d2 100644 --- a/addon-register.js +++ b/addon-register.js @@ -29,13 +29,13 @@ const _patch_eis = () => { args.actor.setupSkill("Résistance", {context : {failure: "1 Point de Corruption reçu", success : "1 Point de Chance gagné"}}).then(setupData => { args.actor.basicTest(setupData).then(test => { - if (test.result.result == "success" && args.actor.data.type == "character") + if (test.result.result == "success" && args.actor.type == "character") { - args.actor.update({"data.status.fortune.value" : args.actor.data.data.status.fortune.value + 1}) + args.actor.update({"system.status.fortune.value" : args.actor.system.status.fortune.value + 1}) } - else if (test.result.result == "failure" && args.actor.data.type == "character") + else if (test.result.result == "failure" && args.actor.type == "character") { - args.actor.update({"data.status.corruption.value" : args.actor.data.data.status.corruption.value + 1}) + args.actor.update({"system.status.corruption.value" : args.actor.system.status.corruption.value + 1}) } }) })` @@ -272,7 +272,7 @@ const __add_actors_translation = () => { const lang = game.settings.get('core', 'language'); if (lang == "fr") { let pack_array = []; - for (let metadata of game.data.packs) { + for (let metadata of game.packs) { if (!game.babele.isTranslated(metadata) && metadata.documentName === 'Actor') { //console.log("PACK : ", metadata); let translations = { diff --git a/babele-register.js b/babele-register.js index f2ceead..e107d18 100644 --- a/babele-register.js +++ b/babele-register.js @@ -250,6 +250,7 @@ Hooks.once('init', () => { var name_en = trait_en.name.trim(); // strip \r in some traits name if ( trait_en.type == "trait") { + console.log("Trait translation", compmod, trait_en) if ( name_en.includes("Tentacles") ) { // Process specific Tentacles case var re = /(.d*)x Tentacles/i; var res = re.exec( name_en ); @@ -263,19 +264,19 @@ Hooks.once('init', () => { special = " (" + game.i18n.localize( res[2].trim() ) + ")"; // And the special keyword } var trait_fr = game.babele.translate( compmod+'.traits', { name: name_en }, true ); - //console.log(">>>>> Trait ?", name_en, nbt, trait_fr, trait_fr.name, special); + console.log(">>>>> Trait ?", name_en, nbt, trait_fr, 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; + if ( trait_fr.system && trait_fr.system.description && 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.eisitems', { name: name_en }, true); 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 ( trait_fr.system && trait_fr.system.description && trait_fr.system.description.value ) + trait_en.system.description.value = trait_fr.system.description.value; } - if ( trait_en.data && trait_en.data.specification && 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() ); + if ( trait_en.system && 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); + trait_en.system.specification.value = game.i18n.localize( trait_en.system.specification.value.trim() ); } } else if ( trait_en.type == "skill") { if ( name_en.includes("(") && name_en.includes(")") ) { // Then process specific skills name with (xxxx) inside @@ -288,8 +289,8 @@ Hooks.once('init', () => { //console.log(">>>>> Skill ?", name_en, special, trait_fr.name, trait_fr); if (trait_fr.name != name_en) { // Translation OK trait_en.name = trait_fr.name + special; - if ( trait_fr.data ) { - trait_en.data.description.value = trait_fr.data.description.value; + if ( trait_fr.system ) { + trait_en.system.description.value = trait_fr.system.description.value; } } @@ -297,8 +298,8 @@ Hooks.once('init', () => { var trait_fr = game.babele.translate( compmod+'.prayers', { name: name_en }, true); //console.log(">>>>> Prayer ?", 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; + if ( trait_fr.system && trait_fr.system.description && trait_fr.system.description.value ) + trait_en.system.description.value = trait_fr.system.description.value; } else if ( trait_en.type == "spell") { var trait_fr = game.babele.translate( compmod+'.spells', { name: name_en }, true); @@ -310,8 +311,8 @@ Hooks.once('init', () => { } //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; + if ( trait_fr.system && trait_fr.system.description && trait_fr.system.description.value ) + trait_en.system.description.value = trait_fr.system.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; @@ -326,21 +327,21 @@ Hooks.once('init', () => { } if ( trait_fr.name == "Sprinter" || trait_fr.name != name_en) { // Talent translated! trait_en.name = trait_fr.name.trim() + special; - if ( trait_fr.data ) { // Why ??? - trait_en.data.description.value = trait_fr.data.description.value; + if ( trait_fr.system ) { // Why ??? + trait_en.system.description.value = trait_fr.system.description.value; } } } else if ( trait_en.type == "career") { var career_fr = game.babele.translate( compmod+'.careers', trait_en, true ); console.log(">>>>> Career ?", name_en, career_fr.name ); trait_en.name = career_fr.name; - trait_en.data = duplicate(career_fr.data); + trait_en.system = duplicate(career_fr.system); } 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 = game.babele.translate( compmod+'.trappings', trait_en, true ); //console.log(">>>>> Trapping ?", name_en, trapping_fr.name); trait_en.name = trapping_fr.name; - if ( trapping_fr.data) { - trait_en.data.description = trapping_fr.data.description; + if ( trapping_fr.system) { + trait_en.system.description = trapping_fr.system.description; } } } diff --git a/compendium/wfrp4e-core.journal-entries.json b/compendium/wfrp4e-core.journal-entries.json index 26c8e73..7ed80de 100644 --- a/compendium/wfrp4e-core.journal-entries.json +++ b/compendium/wfrp4e-core.journal-entries.json @@ -655,6 +655,11 @@ "id": "Zahnstadt", "name": "Zahnstadt", "description": "
\n
\n
\n

Isolated Zahnstadt is considered by locals to be the ‘last village of the Vorbergland’, after which the rolling hills turn barren and cold before reaching upwards to the Greenskin-infested @JournalEntry[The Grey Mountains]{Grey Mountains}. In the shadow of those peaks, Zahnstadt skulks along the southern bank of the River Mos, deep in a dark valley with bleak crags rising to all sides. In summer, the sun only shines on the village for an hour or two at midday, hiding behind the surrounding cliffs in the morning, and creeping behind the mountains as the day lengthens.

\n

In the winter, there is no direct sunlight at all, locking the village in a gloomy cycle of twilight and darkness. Despite this, the folk of Zahnstadt are famous for their bright dispositions and perpetual cheerfulness, a trait outsiders often find forced and off-putting. Every house in Zahnstadt is brightly painted in a garish medley of different, often clashing colors. Its homely inn, the Wayward Sun, is famous for its ever-burning hearthfire and for the relentlessly cheerful songs that echo long into the night.

\n

 

\n
\n
\n
\n
\n

The Sins of the Past

\n

Zahnstadt has long been in the grip of something far worse than a lack of enriching sunlight: vampires. near the end of the third vampire wars, Janos von Carstein deserted the vampire lord Mannfred von Carstein’s depleted armies. After weeks of evading pursuit from his master’s vengeful minions, he chanced upon dark Zahnstadt and realized it was the perfect place to go to ground. Almost three-hundred years later, and he hides there still, and time has made him bold. he now sleeps beneath the Wayward Sun in an ostentatious, velvet-lined coffin, rising each evening to hold ‘court’ in the inn, forcing enthralled locals to sing happy songs of his homeland Sylvania. Rumour of this has not only reached the ears of witch hunters, but also the pawns of recently resurrected Mannfred von Carstein, who has ordered his traitorous son be brought before him. it would be unfortunate, indeed, should poor, unsuspecting souls happen to hostel in the Wayward Sun on the same night the witch hunters arrive to investigate, and the same night that Mannfred’s agents choose to extract Janos before the witch hunters uncover his true nature…

\n
\n

 

\n
    \n
  • The Wolves of Ulric: A ragged band of Ulricans have built a temple to the Lord of Winter in the hollow of the mightiest crag near Zahnstadt. The band preach that the village is sacred to Ulric, for nowhere in Reikland is so frozen in winter, yet the folk survive. Zahnstadt locals are initially happy to welcome these newcomers. But when they start breeding wolves in their temple, and the howling begins, the villagers are eager to find someone to encourage the Ulricans to leave. This need becomes especially pressing when it becomes clear the rowdy cultists are somehow immune to the charms of the village’s mysterious benefactor…
  • \n
\n
\n
\n
\n
\n
\n
" - } + }, + { + "id": "Advisor", + "name": "Conseiller", + "description": "
\n

« Sigmar vaut trois voix pour le Reikland. L’Empereur mort, le Moot et Reikland vont voter de la même façon, ce qui va donner six voix pour le Reikland. Étant donné qu’ Ar’Ulric vote toujours pour le Middenheim, il est fort peu probable que le trône impérial revienne à Nuln alors que la Maison de Wilhelm III est en pleine expansion. Meilleure configuration pour une fille, votre Grâce. Une fille mariable. »

\n

– Krammond, Conseiller de la Cour des Électeurs de Nuln, 2475 CI

\n
\n
\n

\n
\n

Plein de sagesse et très bien renseigné, vous fournissez conseils et aides qui garantissent la prospérité de vos clients.

\n

Les Conseillers fournissent des conseils à ceux qui les emploient. Ils sont très au fait des conditions sociales et politiques du domaine de leur employeur et détiennent maintes informations confidentielles et sensibles. Alors que de nombreux Conseillers le sont de génération en génération, d’autres sont à la recherche active de nobles clients afin d’atteindre un certain niveau de richesse et de pouvoir. Certains jeunes héritiers vont nommer premier Assisant un ami d’enfance ou un camarade d’université, en qui ils ont une confiance aveugle.

\n

De longues années passées à la cour ou au service d’un noble de petite envergure sont nécessaires pour parvenir aux plus hautes responsabilités. De nombreux conseillers ont choisi de ne pas se mettre au service de la noblesse, mais au contraire de proposer leur large éventail de connaissances à des criminels, des seigneurs de guerre, des marchands, des cultes ou encore des guildes.

\n

Si quelque chose d’anormal ou de dangereux se produit sur le domaine de leur employeur, alors un Conseiller est le mieux placé pour enquêter. Aux plus hauts niveaux de la Carrière, un Consultant ou un Chancelier auront leur propre personnel de confiance sur lequel ils peuvent compter pour veiller sur leurs affaires pendant une courte absence. Les Conseillers peuvent approcher différentes catégories de personnes, y compris les plus difficiles d’accès, et sont déjà dans une position où ils sont censés poser des questions au nom de leur employeur.

\n

\n

Races: Elfe sylvain, Halfling, Haut Elfe, Humain, Nain

\n

Classe: Courtisan

\n

Schéma de Progression de Conseiller

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
CCCTFEIAgDexIntFMSoc
III IIIIVII
\n

I. @Compendium[wfrp4e-core.careers.WBA0vgLdGsJ32ccS]{Assistant}

\n

Statut: Argent 2
Compétences: @Compendium[wfrp4e-core.skills.61L9aX2z164cjm7K]{Langue (Classique)}, @Compendium[wfrp4e-core.skills.pKLMbmG3Ivt6mzMf]{Marchandage}, @Compendium[wfrp4e-core.skills.Fs06sr7y9JKpVQmB]{Perception}, @Compendium[wfrp4e-core.skills.RLQHm1s4IuY9RSr2]{Ragot}, @Compendium[wfrp4e-core.skills.CcNJsS4jSwB6Ug1J]{Résistance}, @Compendium[wfrp4e-core.skills.R2ytluHiEFF2KQ5e]{Résistance à l'alcool}, @Compendium[wfrp4e-core.skills.DRO5DLF6UcfkvNSh]{Savoir (Politique)}, @Compendium[wfrp4e-core.skills.d3VZwO4Y5JH5DXdT]{Subornation}
Talents: @Compendium[wfrp4e-core.talents.5KP9sOoLSGvj9EXp]{Insignifiant}, @Compendium[wfrp4e-core.talents.GogGbYxkVdCmiKqf]{Lire/Ecrire}, @Compendium[wfrp4e-core.talents.sYbgpSnRqSZWgwFP]{Savoir-vivre (au choix)}, @Compendium[wfrp4e-core.talents.8lSoPDGrmeTIaapm]{Sociable}
Possessions: nécessaire d’écriture

\n

II. @Compendium[wfrp4e-core.careers.TolERlCR35zIf9G4]{Conseiller}

\n

Statut: Argent 4
Compétences: @Compendium[wfrp4e-core.skills.pxNjTxsp1Kp0SmQe]{Calme}, @Compendium[wfrp4e-core.skills.exLrBrn2mjb6x2Cq]{Charme}, @Compendium[wfrp4e-core.skills.bSWoV1IiS5qWNw39]{Evaluation}, @Compendium[wfrp4e-core.skills.cYtU0ORRFCOpQLWz]{Intuition}, @Compendium[wfrp4e-core.skills.7pQo66cESWttzIlb]{Pari}, @Compendium[wfrp4e-core.skills.DRO5DLF6UcfkvNSh]{Savoir (Région)}
Talents: @Compendium[wfrp4e-core.talents.77p3QRKgFWakkndF]{Baratiner}, @Compendium[wfrp4e-core.talents.aZavWXbSXVBmWeJi]{Coopératif}, @Compendium[wfrp4e-core.talents.r180vP86SlwyJc8W]{Criminel}, @Compendium[wfrp4e-core.talents.b4x1qEWcevX7xK58]{Intrigant}
Possessions: livrée

\n

III. @Compendium[wfrp4e-core.careers.G9PT2bovEv02sVJJ]{Consultant}

\n

Statut: Or 1
Compétences: @Compendium[wfrp4e-core.skills.oMaJZ5cvCJeOUq9H]{Commandement}, @Compendium[wfrp4e-core.skills.qBm2fu3oMhxsDBNQ]{Divertissement (Narration)}, @Compendium[wfrp4e-core.skills.XQiiwS9m2Du1IMUz]{Langue (au choix)}, @Compendium[wfrp4e-core.skills.DRO5DLF6UcfkvNSh]{Savoir (au choix)}
Talents: @Compendium[wfrp4e-core.talents.41JhsSNW1Ttza3JK]{Ergoteur}, @Compendium[wfrp4e-core.talents.LzgxyMknSHjSkkeQ]{Menteur}, @Compendium[wfrp4e-core.talents.hTgrGkWnmIR4xhVe]{Noctambule}, @Compendium[wfrp4e-core.talents.34EBUkHQkrqF1sq7]{Suborneur}
Possessions: vêtements de qualité, assistant

\n

IV. @Compendium[wfrp4e-core.careers.SM95bBsq3ZUFo3YB]{Chancelier}

\n

Statut: Or 3
Compétences: @Compendium[wfrp4e-core.skills.oSbEE6eXH1S3LfUU]{Chevaucher (Cheval)}, @Compendium[wfrp4e-core.skills.DiP9cmbqUir3HkkK]{Savoir (Héraldique)}
Talents: @Compendium[wfrp4e-core.talents.LPgjE0cexTVOBVCY]{Affable}, @Compendium[wfrp4e-core.talents.RbnrfHf7GSQap0ig]{Caïd}, @Compendium[wfrp4e-core.talents.HIofcsDLjXGKzSZf]{Escroquer}, @Compendium[wfrp4e-core.talents.x8g3U68oi8XzWiYr]{Présence imposante}
Possessions: cheval de selle avec selle et harnais, costume luxueux et d’excellente qualité, suite de Conseillers et d’Assistants


" + } ] } \ No newline at end of file diff --git a/module.json b/module.json index de31264..aa59054 100644 --- a/module.json +++ b/module.json @@ -8,7 +8,7 @@ } ], "url": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr", - "version": "6.2.3", + "version": "6.2.4", "esmodules": [ "babele-register.js", "addon-register.js", @@ -136,7 +136,7 @@ } ], "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-6.2.3.zip", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/archive/foundryvtt-wh4-lang-fr-6.2.4.zip", "id": "wh4-fr-translation", "compatibility": { "minimum": "10", diff --git a/modules/import-stat-2.js b/modules/import-stat-2.js index a7e1ceb..18aa7b7 100644 --- a/modules/import-stat-2.js +++ b/modules/import-stat-2.js @@ -134,7 +134,7 @@ async function __findSkill(skillName, value = undefined) { let spec = XRegExp.replace(skillSplit.specialized, "(", ""); spec = XRegExp.replace(spec, ")", ""); let skillSplit2 = XRegExp.exec(dbSkill.name, XRegExp(parseStr, 'gi')); - dbSkill.data.update( { name: skillSplit2.name + '(' + game.i18n.localize( spec.trim() ) + ')' } ); + dbSkill.update( { name: skillSplit2.name + '(' + game.i18n.localize( spec.trim() ) + ')' } ); } //game.babele.translate('wfrp4e-core.skills', dbSkill); return dbSkill; @@ -169,7 +169,7 @@ async function __findTalent(talentName) { if ( talentSplit.specialized ) { let spec = XRegExp.replace(talentSplit.specialized, "(", ""); spec = XRegExp.replace(spec, ")", ""); - dbTalent.data.update( { name: talentSplit.name + '(' + game.i18n.localize( spec.trim() ) + ')' } ); + dbTalent.update( { name: talentSplit.name + '(' + game.i18n.localize( spec.trim() ) + ')' } ); } return dbTalent; } @@ -285,9 +285,9 @@ export default async function statParserFR(statString, type = "npc") { if (itemFound && value && value.length > 0) { if (name.toLowerCase() == 'weapon' || name.toLowerCase() == "bite" || name.toLowerCase() == "tail" || name.toLowerCase() == 'arme' || name.toLowerCase() == "morsure" || name.toLowerCase() == "queue") { - itemFound.data.specification.value = Number(value) - Math.floor( Number(model.characteristics.s.initial) / 10) + itemFound.system.specification.value = Number(value) - Math.floor( Number(model.characteristics.s.initial) / 10) } else { - itemFound.data.specification.value = game.i18n.localize(value) + itemFound.system.specification.value = game.i18n.localize(value) } } if (!itemFound) @@ -301,7 +301,7 @@ export default async function statParserFR(statString, type = "npc") { if (itemFound) itemFound = itemFound.toObject(); if (itemFound && subres && value) { - itemFound.data.advances.value = Number(value) - Number(model.characteristics[itemFound.data.characteristic.value].initial); + itemFound.system.advances.value = Number(value) - Number(model.characteristics[itemFound.system.characteristic.value].initial); } if (!itemFound) ui.notifications.error("Compétence non trouvée, à ajouter manuellement : " + name, { permanent: true }) @@ -313,7 +313,7 @@ export default async function statParserFR(statString, type = "npc") { if (itemFound) itemFound = itemFound.toObject(); if (itemFound && subres && value) - itemFound.data.advances.value = Number(value); + itemFound.system.advances.value = Number(value); if (!itemFound) ui.notifications.error("Talent non trouvé, à ajouter manuellement : " + name, { permanent: true }) } else if (def.name == 'trapping') { @@ -323,7 +323,7 @@ export default async function statParserFR(statString, type = "npc") { catch { } if (!itemFound && name) { itemFound = new game.entities.ItemWfrp4e({ img: "systems/wfrp4e/icons/blank.png", name: name, type: "trapping", data: game.system.model.Item.trapping }) - itemFound.data.data.trappingType.value = "misc" + itemFound.system.trappingType.value = "misc" } if (itemFound) itemFound = itemFound.toObject(); @@ -342,13 +342,13 @@ export default async function statParserFR(statString, type = "npc") { } } let moneyItems = await game.wfrp4e.utility.allMoneyItems() || []; - moneyItems = moneyItems.sort((a, b) => (a.data.coinValue.value > b.data.coinValue.value) ? -1 : 1); - moneyItems.forEach(m => m.data.quantity.value = 0) + moneyItems = moneyItems.sort((a, b) => (a.system.coinValue.value > b.system.coinValue.value) ? -1 : 1); + moneyItems.forEach(m => m.system.quantity.value = 0) globalItemList = globalItemList.concat(moneyItems); //console.log("My liste :", globalItemList); let name = pnjName; - let effects = globalItemList.reduce((total, globItem) => total.concat(globItem.data.effects), []) + let effects = globalItemList.reduce((total, globItem) => total.concat(globItem.effects), []) effects = effects.filter(e => !!e) effects = effects.filter(e => e.transfer)