diff --git a/babele-register.js b/babele-register.js index a380cf5..0ab0821 100644 --- a/babele-register.js +++ b/babele-register.js @@ -148,7 +148,7 @@ Hooks.once('init', () => { module: 'wh4-fr-translation', lang: 'fr', dir: 'compendium' - }); + }) Babele.get().registerConverters({ @@ -161,6 +161,7 @@ Hooks.once('init', () => { for (i = 0; i < len; i++) { skills_list[i] = skills_list[i].trim(); var transl = game.babele.translate(compmod+'.skills', { name: skills_list[i] }, true ).name; + if (!transl) transl = skills_list[i] //console.log("List ...", skills_list[i]); if ( transl == skills_list[i] ) { var res = re.exec( skills_list[i] ); @@ -206,6 +207,7 @@ Hooks.once('init', () => { var re = /(.*)\((.*)\)/i; for (i = 0; i < len; i++) { var transl = game.babele.translate(compmod+'.talents', { name: talents_list[i]}, true ).name; + if (!transl) transl = talents_list[i] if ( transl == talents_list[i] ) { var res = re.exec( talents_list[i]); if (res) { @@ -251,7 +253,7 @@ Hooks.once('init', () => { var special = ""; var nbt = ""; var name_en = trait_en.name.trim(); // strip \r in some traits name - if (trait_en.name.length == 0) { + if (!trait_en.name || trait_en.name.length == 0) { console.log("Wrong item name found!!!!") continue } @@ -306,20 +308,20 @@ Hooks.once('init', () => { } else if ( trait_en.type == "prayer") { var trait_fr = game.babele.translate( compmod+'.prayers', { name: name_en }, true); //console.log(">>>>> Prayer ?", name_en, special, trait_fr.name ); - trait_fr.name = trait_fr.name || trait_en.name + trait_fr.name = trait_fr.name || name_en trait_en.name = trait_fr.name + special; 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) - trait_fr.name = trait_fr.name || name_en if ( trait_fr.name == name_en ) { // If no translation, test eisspells trait_fr = game.babele.translate( 'wfrp4e-eis.eisspells', { name: name_en }, true); } if ( trait_fr.name == name_en ) { // If no translation, test unofficial grimoire trait_fr = game.babele.translate( 'wfrp4e-unofficial-grimoire.ug-spells', { name: name_en }, true); } + trait_fr.name = trait_fr.name || name_en //console.log(">>>>> Spell ?", name_en, special, trait_fr.name ); trait_en.name = trait_fr.name + special; if ( trait_fr.system && trait_fr.system.description && trait_fr.system.description.value ) @@ -345,14 +347,14 @@ Hooks.once('init', () => { } } 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.name + career_fr.name = career_fr.name || trait_en.name + console.log(">>>>> Career ?", career_fr.name ); 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 || trait_en.name + trapping_fr.name = trapping_fr.name || trait_en.name if ( trapping_fr.system) { trait_en.system.description = trapping_fr.system.description; } @@ -363,8 +365,12 @@ Hooks.once('init', () => { }, // To avoid duplicateing class for all careers "generic_localization": (value) => { - if ( value ) - return game.i18n.localize( value.trim() ); + let ret = value + if ( value ) { + ret = game.i18n.localize( value.trim() ); + if (!ret) ret = value + } + return ret }, "trapping_qualities_flaws": (value) => { if ( value ) { @@ -384,7 +390,9 @@ Hooks.once('init', () => { newQF[i].name = "TrapBlade"; // Auto-patch, without space! //console.log("PATCHED", trim); } - newQF[i].name = game.i18n.localize( newQF[i].name ) ; + let oldName = newQF[i].name + newQF[i].name = game.i18n.localize( oldName ) + if (!newQF[i].name) newQF[i].name = oldName } return newQF; } @@ -400,10 +408,13 @@ Hooks.once('init', () => { } // Per default var compendium = game.packs.find(p => p.collection === compmod+'.careers'); - if ( compendium ) - return game.babele.translate(compmod+'.careers', { name: value } ).name; - else + if ( compendium ) { + let newName = game.babele.translate(compmod+'.careers', { name: value } ).name + if (!newName) newName = value + return newName + } else { ui.notifications.error("Impossible de trouver la carrière " + value + ". Elle n'est probablement pas traduite.", { permanent: true }) + } }, "mutations_modifier": (value) => { // This is really UGLYYYY i know, but i started like this and discovered afterward that many strings were not easy to automate... Sorry :) //console.log("Parsing mutation :", value); @@ -434,7 +445,7 @@ Hooks.once('init', () => { return value; }, "talent_name": (name, translation) => { - console.log("NAME !!!", name, translation); + console.log("NAME !!!", name, translation) }, "effects": (effects, translations) => { if ( !effects) return; diff --git a/module.json b/module.json index c8aeeb0..4e66124 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.8", + "version": "6.2.9", "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.8.zip", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/archive/foundryvtt-wh4-lang-fr-6.2.9.zip", "id": "wh4-fr-translation", "compatibility": { "minimum": "10",