Minor translations fixes

This commit is contained in:
2025-04-30 13:57:34 +02:00
parent 05b9dab747
commit 67b2af882f
33 changed files with 113 additions and 106 deletions

View File

@@ -32,7 +32,7 @@ const __SELECT_BONUS_PREFIX_D = {
/************************************************************************************/
export class WFRP4FrTranslation {
static parseSpellContent(spell) {
if (spell.system.range?.value) {
spell.system.range.value = this.processSpellContent(spell.system.range.value)
@@ -55,7 +55,7 @@ export class WFRP4FrTranslation {
//console.log("Spell duration/range/damage/target :", value);
if (value == "") return ""; // Hop !
if (value == "Touch") return "Contact"; // Hop !
if (value == "You") return "Vous"; // Hop !
if (value == "You") return "Vous"; // Hop !
if (value == "Instant") return "Instantané"; // Hop !
let translw = value;
let re = /(.*)\s+[Bb]onus\s*(\w*)/i;
@@ -63,7 +63,7 @@ export class WFRP4FrTranslation {
//console.log("RES1:", res);
let unit = "";
if (res) { // Test "<charac> Bonus <unit>" pattern
if (res[1]) { // We have char name, then convert it
if (res[1]) { // We have char name, then convert it
translw = game.i18n.localize(res[1].trim());
let bonusPrefix = (translw.toLowerCase() in __SELECT_BONUS_PREFIX_D) ? "Bonus d'" : "Bonus de ";
translw = bonusPrefix + translw
@@ -75,7 +75,7 @@ export class WFRP4FrTranslation {
if (res) { // Test : "<number> <unit>" pattern
translw = res[1];
unit = res[2];
} else { // Test
} else { // Test
re = /(\w+) (\w+)/i;
res = re.exec(value);
if (res) { // Test : "<charac> <unit>" pattern
@@ -102,7 +102,7 @@ export class WFRP4FrTranslation {
/************************************************************************************/
Hooks.once('init', () => {
// Check various settings in the installation
// Check various settings in the installation
game.modules.forEach((module, id) => {
if (id == "wfrp4e-core" && module.active) {
compmod = "wfrp4e-core";
@@ -116,7 +116,7 @@ Hooks.once('init', () => {
game.wfrp4e.apps.StatBlockParser.parseStatBlock = async function (statString, type = "npc") {
return statParserFR(statString, type);
}
console.log("WFRP4E-FR | Loading Babele translation module ...");
loadScripts();
@@ -289,7 +289,7 @@ Hooks.once('init', () => {
if (script?.label) {
// Quand le label du script est strictement identique au nom de l'item concerné
if ( script.label.toLowerCase() == origName.toLowerCase() ) {
script.label = e.name
script.label = e.name
} else if (script.label.toLowerCase().includes("tests to affect")) {
script.label = script.label.replace("Tests to affect", "Tests relatifs à ")
} else if (script.label.toLowerCase().includes("using torn muscle")) {
@@ -325,7 +325,7 @@ Hooks.once('init', () => {
for (let data of results) {
let career = data.text.match(/{(.*)}/)
//console.log(">>>>>", career)
if (career && career[1]) {
if (career?.[1]) {
let careerFR = game.babele.converters.career_careergroup(career[1])
data.text = data.text.replace(career[1], careerFR)
}
@@ -338,7 +338,6 @@ Hooks.once('init', () => {
},
"npc_details": (details) => {
//console.log("DETAILS: ", details);
let newDetails = foundry.utils.duplicate(details);
if (details.species?.value)
newDetails.species.value = game.i18n.localize(details.species.value);
@@ -359,9 +358,12 @@ Hooks.once('init', () => {
for (let compData of validCompendiums) {
let translItem = game.babele.translate(compData.metadata.id, { name: talents_list[i] }, true);
// Specific case management
if (talents_list[i] === "Trapper") {
if (talents_list[i] === "Trapper") {
translItem = game.babele.translate(compData.metadata.id, { name: "a7v422EZcOUUC20X" }, true);
}
if (talents_list[i] === "Inspiring") {
translItem = game.babele.translate(compData.metadata.id, { name: "WCXnFSV4WOSmzzc4" }, true);
}
//console.log("Search talent name:", compData.metadata.id, talents_list[i], translItem);
let transl = translItem?.name || undefined
if (!transl) transl = talents_list[i]
@@ -372,7 +374,6 @@ Hooks.once('init', () => {
let s1 = res[1].trim(); // No () in talents table
translItem = game.babele.translate(compData.metadata.id, { name: s1 }, true)
let translw = translItem?.name || undefined
//console.log("Search talent name:", compData.metadata.id, s1, translw);
if (translw && translw != s1) {
transl = translw + " (" + subword + ")";
}
@@ -389,7 +390,7 @@ Hooks.once('init', () => {
"npc_characteristics": (chars) => { // Auto-convert char names in the sheet
for (let key in chars) {
let char = chars[key];
//console.log("Was here !", key, char );
//console.log("Was here !", key, char );
let abrev = char["abrev"];
let toTransl = "CHAR." + abrev;
if (game.i18n.localize(toTransl) != toTransl) { // Manages unknown language
@@ -436,7 +437,7 @@ Hooks.once('init', () => {
trait_en.name = nbt + trait_fr.name + special;
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
//console.log("Translating : ", trait_en.system.specification.value);
//console.log("Translating : ", trait_en.system.specification.value);
trait_en.system.specification.value = game.i18n.localize(trait_en.system.specification.value.trim());
}
break // Translation has been found, skip other compendiums
@@ -479,7 +480,7 @@ Hooks.once('init', () => {
let validCompendiums = game.wfrp4e.tags.getPacksWithTag("spell")
for (let compData of validCompendiums) {
let trait_fr = game.babele.translate(compData.metadata.id, { name: name_en }, true)
if (trait_fr?.system) {
if (trait_fr?.system) {
//DEBUG : console.log(">>>>> Spell ?", name_en, special, trait_fr);
WFRP4FrTranslation.parseSpellContent(trait_en)
trait_fr.name = trait_fr.name || name_en
@@ -499,6 +500,12 @@ Hooks.once('init', () => {
}
let validCompendiums = game.wfrp4e.tags.getPacksWithTag("talent")
for (let compData of validCompendiums) {
if (name_en === "Trapper") {
name_en = "a7v422EZcOUUC20X"
}
if (name_en === "Inspiring") {
name_en = "WCXnFSV4WOSmzzc4"
}
let trait_fr = game.babele.translate(compData.metadata.id, { name: name_en }, true)
if (trait_fr?.system) {
trait_fr.name = trait_fr.name || name_en // Security since babele v10