Fix Traits translation

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

View File

@ -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;
}
}
}