Fix Traits translation

This commit is contained in:
sladecraven 2022-09-30 20:56:12 +02:00
parent be09aec8cd
commit f916c14848
5 changed files with 43 additions and 37 deletions

View File

@ -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.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 => 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'); const lang = game.settings.get('core', 'language');
if (lang == "fr") { if (lang == "fr") {
let pack_array = []; let pack_array = [];
for (let metadata of game.data.packs) { for (let metadata of game.packs) {
if (!game.babele.isTranslated(metadata) && metadata.documentName === 'Actor') { if (!game.babele.isTranslated(metadata) && metadata.documentName === 'Actor') {
//console.log("PACK : ", metadata); //console.log("PACK : ", metadata);
let translations = { let translations = {

View File

@ -250,6 +250,7 @@ Hooks.once('init', () => {
var name_en = trait_en.name.trim(); // strip \r in some traits name var name_en = trait_en.name.trim(); // strip \r in some traits name
if ( trait_en.type == "trait") { if ( trait_en.type == "trait") {
console.log("Trait translation", compmod, trait_en)
if ( name_en.includes("Tentacles") ) { // Process specific Tentacles case if ( name_en.includes("Tentacles") ) { // Process specific Tentacles case
var re = /(.d*)x Tentacles/i; var re = /(.d*)x Tentacles/i;
var res = re.exec( name_en ); var res = re.exec( name_en );
@ -263,19 +264,19 @@ 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 = game.babele.translate( compmod+'.traits', { name: name_en }, true ); 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; trait_en.name = nbt + trait_fr.name + special;
if ( trait_fr.data && trait_fr.data.description && trait_fr.data.description.value ) { if ( trait_fr.system && trait_fr.system.description && trait_fr.system.description.value ) {
trait_en.data.description.value = trait_fr.data.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 } 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_fr = game.babele.translate( 'wfrp4e-eis.eisitems', { name: name_en }, true);
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.system && trait_fr.system.description && trait_fr.system.description.value )
trait_en.data.description.value = trait_fr.data.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 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.data.specification.value); //console.log("Translating : ", trait_en.system.specification.value);
trait_en.data.specification.value = game.i18n.localize( trait_en.data.specification.value.trim() ); trait_en.system.specification.value = game.i18n.localize( trait_en.system.specification.value.trim() );
} }
} else if ( trait_en.type == "skill") { } else if ( trait_en.type == "skill") {
if ( name_en.includes("(") && name_en.includes(")") ) { // Then process specific skills name with (xxxx) inside 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); //console.log(">>>>> Skill ?", name_en, special, trait_fr.name, trait_fr);
if (trait_fr.name != name_en) { // Translation OK if (trait_fr.name != name_en) { // Translation OK
trait_en.name = trait_fr.name + special; trait_en.name = trait_fr.name + special;
if ( trait_fr.data ) { if ( trait_fr.system ) {
trait_en.data.description.value = trait_fr.data.description.value; 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); var trait_fr = game.babele.translate( compmod+'.prayers', { name: name_en }, true);
//console.log(">>>>> Prayer ?", name_en, special, trait_fr.name ); //console.log(">>>>> Prayer ?", 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.system && trait_fr.system.description && trait_fr.system.description.value )
trait_en.data.description.value = trait_fr.data.description.value; trait_en.system.description.value = trait_fr.system.description.value;
} else if ( trait_en.type == "spell") { } else if ( trait_en.type == "spell") {
var trait_fr = game.babele.translate( compmod+'.spells', { name: name_en }, true); 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 ); //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.system && trait_fr.system.description && trait_fr.system.description.value )
trait_en.data.description.value = trait_fr.data.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 if ( name_en.includes("(") && name_en.includes(")") ) { // Then process specific skills name with (xxxx) inside
var re = /(.*) +\((.*)\)/i; var re = /(.*) +\((.*)\)/i;
@ -326,21 +327,21 @@ Hooks.once('init', () => {
} }
if ( trait_fr.name == "Sprinter" || trait_fr.name != name_en) { // Talent translated! if ( trait_fr.name == "Sprinter" || trait_fr.name != name_en) { // Talent translated!
trait_en.name = trait_fr.name.trim() + special; trait_en.name = trait_fr.name.trim() + special;
if ( trait_fr.data ) { // Why ??? if ( trait_fr.system ) { // Why ???
trait_en.data.description.value = trait_fr.data.description.value; trait_en.system.description.value = trait_fr.system.description.value;
} }
} }
} else if ( trait_en.type == "career") { } else if ( trait_en.type == "career") {
var career_fr = game.babele.translate( compmod+'.careers', trait_en, true ); var career_fr = game.babele.translate( compmod+'.careers', trait_en, true );
console.log(">>>>> Career ?", name_en, career_fr.name ); console.log(">>>>> Career ?", name_en, career_fr.name );
trait_en.name = 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") { } 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 ); var trapping_fr = game.babele.translate( compmod+'.trappings', trait_en, true );
//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;
if ( trapping_fr.data) { if ( trapping_fr.system) {
trait_en.data.description = trapping_fr.data.description; trait_en.system.description = trapping_fr.system.description;
} }
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -8,7 +8,7 @@
} }
], ],
"url": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr", "url": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr",
"version": "6.2.3", "version": "6.2.4",
"esmodules": [ "esmodules": [
"babele-register.js", "babele-register.js",
"addon-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", "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", "id": "wh4-fr-translation",
"compatibility": { "compatibility": {
"minimum": "10", "minimum": "10",

View File

@ -134,7 +134,7 @@ async function __findSkill(skillName, value = undefined) {
let spec = XRegExp.replace(skillSplit.specialized, "(", ""); let spec = XRegExp.replace(skillSplit.specialized, "(", "");
spec = XRegExp.replace(spec, ")", ""); spec = XRegExp.replace(spec, ")", "");
let skillSplit2 = XRegExp.exec(dbSkill.name, XRegExp(parseStr, 'gi')); 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); //game.babele.translate('wfrp4e-core.skills', dbSkill);
return dbSkill; return dbSkill;
@ -169,7 +169,7 @@ async function __findTalent(talentName) {
if ( talentSplit.specialized ) { if ( talentSplit.specialized ) {
let spec = XRegExp.replace(talentSplit.specialized, "(", ""); let spec = XRegExp.replace(talentSplit.specialized, "(", "");
spec = XRegExp.replace(spec, ")", ""); 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; return dbTalent;
} }
@ -285,9 +285,9 @@ export default async function statParserFR(statString, type = "npc") {
if (itemFound && value && value.length > 0) { if (itemFound && value && value.length > 0) {
if (name.toLowerCase() == 'weapon' || name.toLowerCase() == "bite" || name.toLowerCase() == "tail" || if (name.toLowerCase() == 'weapon' || name.toLowerCase() == "bite" || name.toLowerCase() == "tail" ||
name.toLowerCase() == 'arme' || name.toLowerCase() == "morsure" || name.toLowerCase() == "queue") { 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 { } else {
itemFound.data.specification.value = game.i18n.localize(value) itemFound.system.specification.value = game.i18n.localize(value)
} }
} }
if (!itemFound) if (!itemFound)
@ -301,7 +301,7 @@ export default async function statParserFR(statString, type = "npc") {
if (itemFound) if (itemFound)
itemFound = itemFound.toObject(); itemFound = itemFound.toObject();
if (itemFound && subres && value) { 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) if (!itemFound)
ui.notifications.error("Compétence non trouvée, à ajouter manuellement : " + name, { permanent: true }) 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) if (itemFound)
itemFound = itemFound.toObject(); itemFound = itemFound.toObject();
if (itemFound && subres && value) if (itemFound && subres && value)
itemFound.data.advances.value = Number(value); itemFound.system.advances.value = Number(value);
if (!itemFound) if (!itemFound)
ui.notifications.error("Talent non trouvé, à ajouter manuellement : " + name, { permanent: true }) ui.notifications.error("Talent non trouvé, à ajouter manuellement : " + name, { permanent: true })
} else if (def.name == 'trapping') { } else if (def.name == 'trapping') {
@ -323,7 +323,7 @@ export default async function statParserFR(statString, type = "npc") {
catch { } catch { }
if (!itemFound && name) { 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 = 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) if (itemFound)
itemFound = itemFound.toObject(); itemFound = itemFound.toObject();
@ -342,13 +342,13 @@ export default async function statParserFR(statString, type = "npc") {
} }
} }
let moneyItems = await game.wfrp4e.utility.allMoneyItems() || []; let moneyItems = await game.wfrp4e.utility.allMoneyItems() || [];
moneyItems = moneyItems.sort((a, b) => (a.data.coinValue.value > b.data.coinValue.value) ? -1 : 1); moneyItems = moneyItems.sort((a, b) => (a.system.coinValue.value > b.system.coinValue.value) ? -1 : 1);
moneyItems.forEach(m => m.data.quantity.value = 0) moneyItems.forEach(m => m.system.quantity.value = 0)
globalItemList = globalItemList.concat(moneyItems); globalItemList = globalItemList.concat(moneyItems);
//console.log("My liste :", globalItemList); //console.log("My liste :", globalItemList);
let name = pnjName; 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)
effects = effects.filter(e => e.transfer) effects = effects.filter(e => e.transfer)