Fix trait translation

This commit is contained in:
LeRatierBretonnien 2023-09-16 15:27:37 +02:00
parent 959e0e0555
commit 0650e39019
2 changed files with 98 additions and 60 deletions

View File

@ -152,7 +152,7 @@ Hooks.once('init', () => {
let compendiumName = 'wfrp4e-core.skills' // Per default let compendiumName = 'wfrp4e-core.skills' // Per default
if (game.system.version.match("7.")) { if (game.system.version.match("7.")) {
compendiumName = 'wfrp4e-core.items' compendiumName = 'wfrp4e-core.items'
} }
//console.log( "Thru here ...", compendium, skills_list); //console.log( "Thru here ...", compendium, skills_list);
if (skills_list) { if (skills_list) {
let i; let i;
@ -198,13 +198,13 @@ Hooks.once('init', () => {
return results return results
} }
// Auto patch // Auto patch
if (results[0].text.includes("wfrp4e-core.career-descriptions") ) { if (results[0].text.includes("wfrp4e-core.career-descriptions")) {
if (game.system.version.match("7.")) { if (game.system.version.match("7.")) {
results[0].text = "wfrp4e-core.journals" results[0].text = "wfrp4e-core.journals"
} else { } else {
results[0].text = "wfrp4e-core.journal-entries" results[0].text = "wfrp4e-core.journal-entries"
} }
} }
if (results[0].text.includes("wfrp4e-core.journal")) { if (results[0].text.includes("wfrp4e-core.journal")) {
for (let data of results) { for (let data of results) {
let career = data.text.match(/{(.*)}/) let career = data.text.match(/{(.*)}/)
@ -237,7 +237,7 @@ Hooks.once('init', () => {
let compendiumName = 'wfrp4e-core.talents' // Per default let compendiumName = 'wfrp4e-core.talents' // Per default
if (game.system.version.match("7.")) { if (game.system.version.match("7.")) {
compendiumName = 'wfrp4e-core.items' compendiumName = 'wfrp4e-core.items'
} }
let i; let i;
if (talents_list) { if (talents_list) {
let len = talents_list.length; let len = talents_list.length;
@ -261,7 +261,7 @@ Hooks.once('init', () => {
if (res2) { if (res2) {
transl = res2[1] + " (" + subword + ")"; transl = res2[1] + " (" + subword + ")";
} else { } else {
transl = translw transl = translw
} }
} }
} }
@ -316,18 +316,23 @@ Hooks.once('init', () => {
let compendiumName = 'wfrp4e-core.traits' // Per default let compendiumName = 'wfrp4e-core.traits' // Per default
if (game.system.version.match("7.")) { if (game.system.version.match("7.")) {
compendiumName = 'wfrp4e-core.items' compendiumName = 'wfrp4e-core.items'
} }
let trait_fr = game.babele.translate(compendiumName, { name: name_en }, true); let trait_fr = game.babele.translate(compendiumName, { 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_fr.name = trait_fr.name || trait_en.name if (trait_fr?.name) {
trait_en.name = nbt + trait_fr.name + special; trait_fr.name = trait_fr.name || trait_en.name
trait_en.name = nbt + trait_fr.name + special;
}
if (trait_fr.system?.description?.value) { if (trait_fr.system?.description?.value) {
trait_en.system.description.value = 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 } 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.items', { name: name_en }, true); trait_fr = game.babele.translate('wfrp4e-eis.items', { name: name_en }, true);
trait_en.name = nbt + trait_fr.name + special; if (trait_fr?.name) {
if (trait_fr.system?.description?.value) trait_en.name = nbt + trait_fr.name + special
trait_en.system.description.value = trait_fr.system.description.value; }
if (trait_fr.system?.description?.value) {
trait_en.system.description.value = trait_fr.system.description.value
}
} }
if (trait_en.system?.specification && isNaN(trait_en.system.specification.value)) { // This is a string, so translate it if (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); //console.log("Translating : ", trait_en.system.specification.value);
@ -343,7 +348,7 @@ Hooks.once('init', () => {
let compendiumSkills = 'wfrp4e-core.skills' // Per default let compendiumSkills = 'wfrp4e-core.skills' // Per default
if (game.system.version.match("7.")) { if (game.system.version.match("7.")) {
compendiumSkills = 'wfrp4e-core.items' compendiumSkills = 'wfrp4e-core.items'
} }
let trait_fr = game.babele.translate(compendiumSkills, { name: name_en }, true); let trait_fr = game.babele.translate(compendiumSkills, { 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);
trait_fr.name = trait_fr.name || name_en trait_fr.name = trait_fr.name || name_en
@ -358,7 +363,7 @@ Hooks.once('init', () => {
let compendiumPrayers = 'wfrp4e-core.prayers' // Per default let compendiumPrayers = 'wfrp4e-core.prayers' // Per default
if (game.system.version.match("7.")) { if (game.system.version.match("7.")) {
compendiumPrayers = 'wfrp4e-core.items' compendiumPrayers = 'wfrp4e-core.items'
} }
let trait_fr = game.babele.translate(compendiumPrayers, { name: name_en }, true); let trait_fr = game.babele.translate(compendiumPrayers, { name: name_en }, true);
//console.log(">>>>> Prayer ?", name_en, special, trait_fr.name ); //console.log(">>>>> Prayer ?", name_en, special, trait_fr.name );
trait_fr.name = trait_fr.name || name_en trait_fr.name = trait_fr.name || name_en
@ -370,7 +375,7 @@ Hooks.once('init', () => {
let compendiumSpells = 'wfrp4e-core.spells' // Per default let compendiumSpells = 'wfrp4e-core.spells' // Per default
if (game.system.version.match("7.")) { if (game.system.version.match("7.")) {
compendiumSpells = 'wfrp4e-core.items' compendiumSpells = 'wfrp4e-core.items'
} }
let trait_fr = game.babele.translate(compendiumSpells, { name: name_en }, true) let trait_fr = game.babele.translate(compendiumSpells, { name: name_en }, true)
if (trait_fr.name == name_en) { // If no translation, test eisspells if (trait_fr.name == name_en) { // If no translation, test eisspells
trait_fr = game.babele.translate('wfrp4e-eis.eisspells', { name: name_en }, true); trait_fr = game.babele.translate('wfrp4e-eis.eisspells', { name: name_en }, true);
@ -383,8 +388,8 @@ Hooks.once('init', () => {
trait_en.name = trait_fr.name + special; trait_en.name = trait_fr.name + special;
if (trait_fr.system?.description?.value) if (trait_fr.system?.description?.value)
trait_en.system.description.value = trait_fr.system.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
let re = /(.*) +\((.*)\)/i; let re = /(.*) +\((.*)\)/i;
let res = re.exec(name_en); let res = re.exec(name_en);
@ -394,7 +399,7 @@ Hooks.once('init', () => {
let compendiumTalents = 'wfrp4e-core.talents' // Per default let compendiumTalents = 'wfrp4e-core.talents' // Per default
if (game.system.version.match("7.")) { if (game.system.version.match("7.")) {
compendiumTalents = 'wfrp4e-core.items' compendiumTalents = 'wfrp4e-core.items'
} }
let trait_fr = game.babele.translate(compendiumTalents, { name: name_en }, true) let trait_fr = game.babele.translate(compendiumTalents, { name: name_en }, true)
trait_fr.name = trait_fr.name || name_en // Security since babele v10 trait_fr.name = trait_fr.name || name_en // Security since babele v10
//console.log(">>>>> Talent ?", trait_fr, name_en, special, trait_fr.name); //console.log(">>>>> Talent ?", trait_fr, name_en, special, trait_fr.name);
@ -412,11 +417,11 @@ Hooks.once('init', () => {
let compendiumCareers = 'wfrp4e-core.careers' // Per default let compendiumCareers = 'wfrp4e-core.careers' // Per default
if (game.system.version.match("7.")) { if (game.system.version.match("7.")) {
compendiumCareers = 'wfrp4e-core.items' compendiumCareers = 'wfrp4e-core.items'
} }
let career_fr = game.babele.translate(compendiumCareers, { name: name_en }, true); let career_fr = game.babele.translate(compendiumCareers, { name: name_en }, true);
trait_en.name = career_fr.name || trait_en.name trait_en.name = career_fr.name || trait_en.name
//console.log(">>>>> Career ?", career_fr.name ); //console.log(">>>>> Career ?", career_fr.name );
if ( career_fr?.system) { if (career_fr?.system) {
trait_en.system = duplicate(career_fr.system); trait_en.system = duplicate(career_fr.system);
} }
@ -424,8 +429,8 @@ Hooks.once('init', () => {
let compendiumTrappings = 'wfrp4e-core.trappings' // Per default let compendiumTrappings = 'wfrp4e-core.trappings' // Per default
if (game.system.version.match("7.")) { if (game.system.version.match("7.")) {
compendiumTrappings = 'wfrp4e-core.items' compendiumTrappings = 'wfrp4e-core.items'
} }
let trapping_fr = game.babele.translate(compendiumTrappings, { name: name_en }, true); let trapping_fr = game.babele.translate(compendiumTrappings, { name: name_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 trait_en.name = trapping_fr.name || trait_en.name
if (trapping_fr.system?.description?.value) { if (trapping_fr.system?.description?.value) {
@ -484,7 +489,7 @@ Hooks.once('init', () => {
let compendiumCareers = 'wfrp4e-core.careers' // Per default let compendiumCareers = 'wfrp4e-core.careers' // Per default
if (game.system.version.match("7.")) { if (game.system.version.match("7.")) {
compendiumCareers = 'wfrp4e-core.items' compendiumCareers = 'wfrp4e-core.items'
} }
let compendium = game.packs.find(p => p.collection === compendiumCareers); let compendium = game.packs.find(p => p.collection === compendiumCareers);
if (compendium) { if (compendium) {
let newName = game.babele.translate(compendiumCareers, { name: value }).name let newName = game.babele.translate(compendiumCareers, { name: value }).name
@ -622,7 +627,7 @@ function registerUsageCount(registerKey) {
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
Hooks.once('ready', () => { Hooks.once('ready', () => {
registerUsageCount("wh4-fr-translation") registerUsageCount("wh4-fr-translation")

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": "7.0.8", "version": "7.0.9",
"esmodules": [ "esmodules": [
"babele-register.js", "babele-register.js",
"addon-register.js", "addon-register.js",
@ -30,107 +30,140 @@
"label": "Plats d'Auberges", "label": "Plats d'Auberges",
"type": "RollTable", "type": "RollTable",
"name": "plats-dauberges", "name": "plats-dauberges",
"path": "packs/plats-dauberges.db", "path": "packs/plats-dauberges",
"system": "wfrp4e", "system": "wfrp4e",
"private": false, "flags": {},
"flags": {} "ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
}
}, },
{ {
"label": "Dons de Rhya", "label": "Dons de Rhya",
"type": "JournalEntry", "type": "JournalEntry",
"name": "dons-de-rhya", "name": "dons-de-rhya",
"path": "packs/dons-de-rhya.db", "path": "packs/dons-de-rhya",
"system": "wfrp4e", "system": "wfrp4e",
"private": false, "flags": {},
"flags": {} "ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
}
}, },
{ {
"label": "Sorts FR", "label": "Sorts FR",
"type": "Item", "type": "Item",
"name": "sort-fr", "name": "sort-fr",
"path": "packs/sort-fr.db", "path": "packs/sort-fr",
"system": "wfrp4e", "system": "wfrp4e",
"private": false, "flags": {},
"flags": {} "ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
}
}, },
{ {
"label": "Aides de Jeu FR", "label": "Aides de Jeu FR",
"type": "JournalEntry", "type": "JournalEntry",
"name": "aides-de-jeu-fr", "name": "aides-de-jeu-fr",
"path": "packs/aides-de-jeu-fr.db", "path": "packs/aides-de-jeu-fr",
"system": "wfrp4e", "system": "wfrp4e",
"private": false, "flags": {},
"flags": {} "ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
}
}, },
{ {
"label": "Potions : Drogues et Sédatifs", "label": "Potions : Drogues et Sédatifs",
"type": "Item", "type": "Item",
"name": "drogues-and-sedatifs", "name": "drogues-and-sedatifs",
"path": "packs/drogues-and-sedatifs.db", "path": "packs/drogues-and-sedatifs",
"system": "wfrp4e", "system": "wfrp4e",
"private": false, "flags": {},
"flags": {} "ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
}
}, },
{ {
"label": "Potions : Pansements et Cataplasmes", "label": "Potions : Pansements et Cataplasmes",
"type": "Item", "type": "Item",
"name": "pansements-and-cataplasmes", "name": "pansements-and-cataplasmes",
"path": "packs/pansements-and-cataplasmes.db", "path": "packs/pansements-and-cataplasmes",
"system": "wfrp4e", "system": "wfrp4e",
"private": false, "flags": {},
"flags": {} "ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
}
}, },
{ {
"label": "Potions : Poisons et Toxiques", "label": "Potions : Poisons et Toxiques",
"type": "Item", "type": "Item",
"name": "poisons-and-toxiques", "name": "poisons-and-toxiques",
"path": "packs/poisons-and-toxiques.db", "path": "packs/poisons-and-toxiques",
"system": "wfrp4e", "system": "wfrp4e",
"private": false, "flags": {},
"flags": {} "ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
}
}, },
{ {
"label": "Potions : Potions et Décoctions", "label": "Potions : Potions et Décoctions",
"type": "Item", "type": "Item",
"name": "potions-and-decoctions", "name": "potions-and-decoctions",
"path": "packs/potions-and-decoctions.db", "path": "packs/potions-and-decoctions",
"system": "wfrp4e", "system": "wfrp4e",
"private": false, "flags": {},
"flags": {} "ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
}
}, },
{ {
"label": "Potions : Antidotes et Remèdes", "label": "Potions : Antidotes et Remèdes",
"type": "Item", "type": "Item",
"name": "antidotes-and-remedes", "name": "antidotes-and-remedes",
"path": "packs/antidotes-and-remedes.db", "path": "packs/antidotes-and-remedes",
"system": "wfrp4e", "system": "wfrp4e",
"private": false, "flags": {},
"flags": {} "ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
}
}, },
{ {
"label": "Tables des Traductions", "label": "Tables des Traductions",
"type": "JournalEntry", "type": "JournalEntry",
"name": "tables-des-traductions", "name": "tables-des-traductions",
"path": "packs/tables-des-traductions.db", "path": "packs/tables-des-traductions",
"system": "wfrp4e", "system": "wfrp4e",
"private": false, "flags": {},
"flags": {} "ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
}
}, },
{ {
"label": "Apothicarium", "label": "Apothicarium",
"type": "JournalEntry", "type": "JournalEntry",
"name": "apothicarium", "name": "apothicarium",
"path": "packs/apothicarium.db", "path": "packs/apothicarium",
"system": "wfrp4e", "system": "wfrp4e",
"private": false, "flags": {},
"flags": {} "ownership": {
"PLAYER": "OBSERVER",
"ASSISTANT": "OWNER"
}
} }
], ],
"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-7.0.8.zip", "download": "https://www.uberwald.me/gitea/public/foundryvtt-wh4-lang-fr-fr/archive/foundryvtt-wh4-lang-fr-7.0.9.zip",
"id": "wh4-fr-translation", "id": "wh4-fr-translation",
"compatibility": { "compatibility": {
"minimum": "11", "minimum": "10",
"verified": "11" "verified": "11"
}, },
"relationships": { "relationships": {