First fixes for 4.0/0.8.X

This commit is contained in:
sladecraven 2021-06-29 09:57:36 +02:00
parent 7ba0d03d56
commit 716a27f6ad
4 changed files with 51 additions and 69 deletions

View File

@ -113,7 +113,7 @@ const __create_translation_tables = async (compmod) => {
* */ * */
const __auto_patch_translation_journal_compendium = async (compmod) => { const __auto_patch_translation_journal_compendium = async (compmod) => {
if (game.user.isGM) { if (game.user.isGM) {
let compData = game.packs.get( "WH4-fr-translation.tables-des-traductions" ); /*let compData = game.packs.get( "WH4-fr-translation.tables-des-traductions" );
compData.locked = false; compData.locked = false;
let translEntries = await compData.getContent(); let translEntries = await compData.getContent();
for (let entryData of translEntries ) { for (let entryData of translEntries ) {
@ -121,7 +121,7 @@ const __auto_patch_translation_journal_compendium = async (compmod) => {
mydata.content = mydata.content.replace(/wfrp4e-content/g, compmod ); mydata.content = mydata.content.replace(/wfrp4e-content/g, compmod );
entryData.update( mydata ); entryData.update( mydata );
} }
compData.locked = true; compData.locked = true;*/
} }
} }
@ -215,11 +215,11 @@ 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 = [];
game.packs.forEach((pack, name) => { for ( let metadata of game.data.packs ) {
let newpack = pack; if(!game.babele.isTranslated(metadata) && metadata.documentName === 'Actor') {
if(!pack.translated && pack.entity === 'Actor') { console.log("PACK : ", metadata);
let translations = { let translations = {
"label": pack.metadata.name, "label": metadata.name,
"mapping": { "mapping": {
"name": "name", "name": "name",
"description": "details.biography.value", "description": "details.biography.value",
@ -239,24 +239,26 @@ const __add_actors_translation = ( ) => {
"entries": [ "entries": [
] ]
}; };
newpack = new TranslatedCompendium(pack, translations); game.babele.packs.set(collection, new TranslatedCompendium(metadata, translation));
console.log("Actor compendium has been replaced !!!!", pack.metadata.name); //newpack = new TranslatedCompendium(pack, translations);
//console.log("Actor compendium has been replaced !!!!", pack.metadata.name);
} }
//console.log("Parsing pack", newpack); console.log("Parsing pack", metadata);
if (newpack.metadata.name == "forien-armoury" ) { if (!game.babele.isTranslated(metadata) && metadata.name == "forien-armoury" ) {
newpack.mapping.mapping["qualities"] = { /** TODO !!!/
metadata.mapping.mapping["qualities"] = {
"path": "data.qualities.value", "path": "data.qualities.value",
"converter": "trapping_qualities_flaws" "converter": "trapping_qualities_flaws"
}; };
newpack.mapping.mapping["flaws"] = { metadata.mapping.mapping["flaws"] = {
"path": "data.flaws.value", "path": "data.flaws.value",
"converter": "trapping_qualities_flaws" "converter": "trapping_qualities_flaws"
}; };
console.log("Forien armoury patched !!");
console.log("Forien armoury patched !!");*/
}
//pack_array.push( [name, newpack ] );
} }
pack_array.push( [name, newpack ] );
} );
game.packs = new Collection( pack_array );
} }
} }

View File

@ -205,8 +205,8 @@ Hooks.once('init', () => {
}); });
Babele.get().registerConverters({ Babele.get().registerConverters({
"career_skills": (skills_list) => { "career_skills": (skills_list) => {
var compendium = game.packs.find(p => p.collection === compmod+'.skills');
//console.log( "Thru here ...", compendium, skills_list); //console.log( "Thru here ...", compendium, skills_list);
if ( skills_list ) { if ( skills_list ) {
var i; var i;
@ -214,7 +214,7 @@ Hooks.once('init', () => {
var re = /(.*)\((.*)\)/i; var re = /(.*)\((.*)\)/i;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
skills_list[i] = skills_list[i].trim(); skills_list[i] = skills_list[i].trim();
var transl = compendium.translate( { name: skills_list[i] } ).name; var transl = game.babele.translate(compmod+'.skills', { name: skills_list[i] }, true ).name;
//console.log("List ...", skills_list[i]); //console.log("List ...", skills_list[i]);
if ( transl == skills_list[i] ) { if ( transl == skills_list[i] ) {
var res = re.exec( skills_list[i] ); var res = re.exec( skills_list[i] );
@ -222,13 +222,13 @@ Hooks.once('init', () => {
//console.log("Matched/split:", res[1], res[2]); //console.log("Matched/split:", res[1], res[2]);
var subword = game.i18n.localize(res[2].trim() ); var subword = game.i18n.localize(res[2].trim() );
var s1 = res[1].trim() + " ()"; var s1 = res[1].trim() + " ()";
var translw = compendium.translate( { name: s1} ).name; var translw = game.babele.translate(compmod+'.skills', { name: s1}, true ).name;
if (translw != s1) { if (translw != s1) {
var res2 = re.exec(translw); var res2 = re.exec(translw);
transl = res2[1] + "(" + subword + ")"; transl = res2[1] + "(" + subword + ")";
} else { } else {
s1 = res[1].trim() + " ( )"; s1 = res[1].trim() + " ( )";
translw = compendium.translate( { name: s1} ).name; translw = game.babele.translate(compmod+'.skills', { name: s1}, true ).name;
var res2 = re.exec(translw); var res2 = re.exec(translw);
transl = res2[1] + "(" + subword + ")"; transl = res2[1] + "(" + subword + ")";
} }
@ -239,6 +239,7 @@ Hooks.once('init', () => {
} }
return skills_list; return skills_list;
}, },
"npc_details": (details) => { "npc_details": (details) => {
//console.log("DETAILS: ", details); //console.log("DETAILS: ", details);
let newDetails = duplicate(details); let newDetails = duplicate(details);
@ -250,6 +251,7 @@ Hooks.once('init', () => {
newDetails.class.value = game.i18n.localize(details.class.value); newDetails.class.value = game.i18n.localize(details.class.value);
return newDetails; return newDetails;
}, },
"career_talents": (talents_list) => { "career_talents": (talents_list) => {
var compendium = game.packs.find(p => p.collection === compmod+'.talents'); var compendium = game.packs.find(p => p.collection === compmod+'.talents');
var i; var i;
@ -257,19 +259,19 @@ Hooks.once('init', () => {
var len = talents_list.length; var len = talents_list.length;
var re = /(.*)\((.*)\)/i; var re = /(.*)\((.*)\)/i;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
var transl = compendium.translate( { name: talents_list[i]} ).name; var transl = game.babele.translate(compmod+'.talents', { name: talents_list[i]}, true ).name;
if ( transl == talents_list[i] ) { if ( transl == talents_list[i] ) {
var res = re.exec( talents_list[i]); var res = re.exec( talents_list[i]);
if (res) { if (res) {
//console.log("Matched/split:", res[1], res[2]); //console.log("Matched/split:", res[1], res[2]);
var subword = game.i18n.localize(res[2].trim() ); var subword = game.i18n.localize(res[2].trim() );
var s1 = res[1].trim(); // No () in talents table var s1 = res[1].trim(); // No () in talents table
var translw = compendium.translate( { name: s1 } ).name; var translw = game.babele.translate(compmod+'.talents', { name: s1 }, true ).name;
if (translw != s1) { if (translw != s1) {
transl = translw + "(" + subword + ")"; transl = translw + "(" + subword + ")";
} else { } else {
s1 = res[1].trim() + " ( )"; s1 = res[1].trim() + " ( )";
translw = compendium.translate( { name: s1 } ).name; translw = game.babele.translate(compmod+'.talents', { name: s1 }, true ).name;
var res2 = re.exec(translw); var res2 = re.exec(translw);
transl = res2[1] + "(" + subword + ")"; transl = res2[1] + "(" + subword + ")";
} }
@ -294,18 +296,6 @@ Hooks.once('init', () => {
return chars; return chars;
}, },
"bestiary_traits": (beast_traits, translations) => { "bestiary_traits": (beast_traits, translations) => {
var fulltraits = game.packs.get(compmod+'.traits');
var fullskills = game.packs.get(compmod+'.skills');
var fulltalents = game.packs.get(compmod+'.talents');
var fullcareers = game.packs.get(compmod+'.careers');
var fulltrappings = game.packs.get(compmod+'.trappings');
var fullspells = game.packs.get(compmod+'.spells');
var fullprayers = game.packs.get(compmod+'.prayers');
var eisitems = game.packs.get('eis.eisitems');
var eisspells = game.packs.get('eis.eisspells');
var ugtalents = game.packs.get('wfrp4e-unofficial-grimoire.ug-careerstalentstraits');
var ugspells = game.packs.get('wfrp4e-unofficial-grimoire.ug-spells');
//console.log("Comp :", compmod, fulltraits);
for (let trait_en of beast_traits) for (let trait_en of beast_traits)
{ {
@ -326,13 +316,13 @@ Hooks.once('init', () => {
name_en = res[1]; // Get the root traits name name_en = res[1]; // Get the root traits name
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 = fulltraits.translate( { name: name_en } ); var trait_fr = game.babele.translate( compmod+'.traits', { name: name_en }, true );
//console.log(">>>>> Trait ?", name_en, nbt, 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.data && trait_fr.data.description && trait_fr.data.description.value ) {
trait_en.data.description.value = 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 } else if ( eisitems ) { // No description in the FR compendium -> test other compendium if presenr
trait_fr = eisitems.translate( { name: name_en } ); trait_fr = game.babele.translate( '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.data && trait_fr.data.description && trait_fr.data.description.value )
trait_en.data.description.value = trait_fr.data.description.value; trait_en.data.description.value = trait_fr.data.description.value;
@ -348,27 +338,29 @@ Hooks.once('init', () => {
name_en = res[1].trim(); // Get the root skill name name_en = res[1].trim(); // Get the root skill name
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 = fullskills.translate( { name: name_en } ); var trait_fr = game.babele.translate( compmod+'.skills', { name: name_en }, true );
//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.translated) { 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.data ) {
trait_en.data.description.value = trait_fr.data.description.value; trait_en.data.description.value = trait_fr.data.description.value;
} }
} }
} else if ( trait_en.type == "prayer") { } else if ( trait_en.type == "prayer") {
var trait_fr = fullprayers.translate( { name: name_en } ); 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.data && trait_fr.data.description && trait_fr.data.description.value )
trait_en.data.description.value = trait_fr.data.description.value; trait_en.data.description.value = trait_fr.data.description.value;
} else if ( trait_en.type == "spell") { } else if ( trait_en.type == "spell") {
var trait_fr = fullspells.translate( { name: name_en } ); var trait_fr = game.babele.translate( compmod+'.spells', { name: name_en }, true);
if ( (!trait_fr.data || !trait_fr.data.description || !trait_fr.data.description.value) && eisspells) { // If no translation, test eisspells if ( trait_fr.name == name_en ) { // If no translation, test eisspells
trait_fr = eisspells.translate( { name: name_en } ); trait_fr = game.babele.translate( 'eis.eisspells', { name: name_en }, true);
} }
if ( (!trait_fr.data || !trait_fr.data.description || !trait_fr.data.description.value) && ugspells) { // If no translation, test eisspells if ( trait_fr.name == name_en ) { // If no translation, test unofficial grimoire
trait_fr = ugspells.translate( { name: name_en } ); trait_fr = game.babele.translate( 'wfrp4e-unofficial-grimoire.ug-spells', { name: name_en }, true);
} }
//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;
@ -381,24 +373,24 @@ Hooks.once('init', () => {
name_en = res[1].trim(); // Get the root talent name, no parenthesis this time... name_en = res[1].trim(); // Get the root talent name, no parenthesis this time...
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 = fulltalents.translate( { name: name_en } ); var trait_fr = game.babele.translate( compmod+'.talents', { name: name_en }, true );
//console.log(">>>>> Talent ?", name_en, special, trait_fr.name); //console.log(">>>>> Talent ?", name_en, special, trait_fr.name);
if ( (!trait_fr.data || !trait_fr.data.description || !trait_fr.data.description.value) && ugtalents) { // If no translation, test ugtalents if ( trait_fr.name == name_en) { // If no translation, test ugtalents
trait_fr = ugtalents.translate( { name: name_en } ); trait_fr = game.babele.translate( 'wfrp4e-unofficial-grimoire.ug-careerstalentstraits', { name: name_en }, true );
} }
if ( trait_fr.translated) { if ( trait_fr.name != name_en) { // Talent translated!
trait_en.name = trait_fr.name + special; trait_en.name = trait_fr.name + special;
if ( trait_fr.data ) { // Why ??? if ( trait_fr.data ) { // Why ???
trait_en.data.description.value = trait_fr.data.description.value; trait_en.data.description.value = trait_fr.data.description.value;
} }
} }
} else if ( trait_en.type == "career") { } else if ( trait_en.type == "career") {
var career_fr = fullcareers.translate( trait_en ); 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.data = duplicate(career_fr.data);
} 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 = fulltrappings.translate( trait_en ); 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.data) {
@ -449,7 +441,7 @@ Hooks.once('init', () => {
// Per default // Per default
var compendium = game.packs.find(p => p.collection === compmod+'.careers'); var compendium = game.packs.find(p => p.collection === compmod+'.careers');
if ( compendium ) if ( compendium )
return compendium.translate( { name: value } ).name; return game.babele.translate(compmod+'.careers', { name: value } ).name;
else else
ui.notifications.error("Impossible de trouver la carrière " + value + ". Elle n'est probablement pas traduite.", { permanent: true }) ui.notifications.error("Impossible de trouver la carrière " + value + ". Elle n'est probablement pas traduite.", { permanent: true })
}, },

View File

@ -2,9 +2,9 @@
"name": "WH4-fr-translation", "name": "WH4-fr-translation",
"title": "WFRP4e - Core Module en français.", "title": "WFRP4e - Core Module en français.",
"description": "Traduction Française pour Warhammer v4.", "description": "Traduction Française pour Warhammer v4.",
"version": "1.6.6", "version": "4.0.0",
"minimumCoreVersion" : "0.7.1", "minimumCoreVersion" : "0.8.0",
"compatibleCoreVersion": "0.8.7", "compatibleCoreVersion": "0.8.8",
"author": "LeRatierBretonnien", "author": "LeRatierBretonnien",
"dependencies": [ "dependencies": [
{ {

File diff suppressed because one or more lines are too long