swade-fr-content-neoflip/module/modules/swade-fr-init.js

225 lines
9.3 KiB
JavaScript
Raw Normal View History

2021-03-15 09:22:27 +01:00
2022-02-05 00:23:39 +01:00
const __compFolderTranslation = [
{
compendium: 'swade-core-rules.swade-vehicles',
words: [
{source: 'Vehicles', translation: 'Véhicules' },
{source: 'Aircraft', translation: 'Avions' },
{source: 'Civilian', translation: 'Civils' },
{source: 'Modern Military Aircraft', translation: 'Avions Militaires Modernes' },
2022-02-06 17:48:39 +01:00
{source: 'World War II Military Aircraft', translation: 'Avions Seconde Guerre Mondiale' },
2022-02-05 00:23:39 +01:00
]
}
]
class FolderTranslate {
static async translateFolders() {
for (let tData of __compFolderTranslation) {
let pack = game.packs.get(tData.compendium);
let wasLocked = false;
if (pack.locked) {
2022-02-06 17:48:39 +01:00
await pack.configure({locked: false})
2022-02-05 00:23:39 +01:00
wasLocked = true;
}
let folders = await game.CF.FICFolderAPI.loadFolders(tData.compendium);
for (let trans of tData.words) {
let folderToChange = folders.contents.find(f => f.name === trans.source );
if (folderToChange ) {
await game.CF.FICFolderAPI.renameFolder(folderToChange, trans.translation);
}
}
if ( wasLocked) {
2022-02-06 17:48:39 +01:00
await pack.configure({locked: true})
2022-02-05 00:23:39 +01:00
}
}
}
}
/************************************************************************************/
Hooks.once('translateCompendiumFolders', () => {
console.log("LOADED !!!!!!")
});
/************************************************************************************/
class swadeFrTranslator {
static getRank( rank) {
if ( rank == 'Novice') return 'Novice';
if ( rank == 'Seasoned') return 'Aguerri';
if ( rank == 'Veteran') return 'Vétéran';
if ( rank == 'Heroic') return 'Héroïque';
if ( rank == 'Legendary') return 'Légendaire';
return false
}
static getAttribute( attr) {
console.log("Attr is", attr)
if ( attr == "Agility") return 'Agilité';
if ( attr == "Smarts") return 'Intellect';
if ( attr == "Spirit") return 'Ame';
if ( attr == "Strength") return 'Force';
if ( attr == "Vigor") return 'Vigueur';
return false
}
}
2021-03-15 09:22:27 +01:00
/************************************************************************************/
Hooks.once('init', () => {
2021-03-28 18:33:31 +02:00
2021-03-15 09:22:27 +01:00
if(typeof Babele !== 'undefined') {
2021-03-15 09:22:27 +01:00
console.log("BABELE LOADED !!!");
Babele.get().register({
2022-04-29 15:30:12 +02:00
module: 'swade-fr-content',
2021-03-15 09:22:27 +01:00
lang: 'fr',
dir: 'compendiums'
});
2021-03-28 18:33:31 +02:00
Babele.get().registerConverters({
2021-11-16 14:53:31 +01:00
"gear_skill": (skill) => {
let transl = skill
2021-11-16 14:53:31 +01:00
if (skill) {
let translated = game.babele.translate( "swade-core-rules.swade-skills", {name: skill.trim()}, true )
transl = translated.name
}
return transl
},
"edge_requirements": (req) => {
let reqTab = req.split(",")
let results = []
for (let item of reqTab) {
let keyName = item.match(/([\w\s\(\)]+) (d[\w\+]*)/)
//console.log("Keyword", item, keyName)
if (keyName && keyName[2]) { // This is a skill or attribute
let toTranslate = keyName[1].trim()
let attr = swadeFrTranslator.getAttribute( toTranslate)
if ( attr) { // Test if attribute
results.push( attr + " " + keyName[2].trim())
} else { // Test if skill
let translated = game.babele.translate( "swade-core-rules.swade-skills", {name: toTranslate}, true )
if ( !translated.name) {
translated = game.babele.translate( "deadlands-core-rules.deadlands-skills", {name: toTranslate }, true )
}
let transResult = translated.name || toTranslate
results.push( transResult + " " + keyName[2].trim() )
}
} else { // Rank or edge
let itemName = item.trim()
let rank = swadeFrTranslator.getRank(itemName)
if (rank) {
results.push( rank )
} else {
let translated = game.babele.translate( "swade-core-rules.swade-edges", {name: itemName }, true )
if ( !translated.name) {
translated = game.babele.translate( "deadlands-core-rules.deadlands-edges", {name: itemName }, true )
}
let transResult = translated.name || itemName
results.push( transResult )
}
}
2021-11-16 14:53:31 +01:00
}
console.log(">>>>>>>>>>>>>>>>>>>>>>>>><REQ !!!!", req, results)
return results.join(", ")
2021-11-16 14:53:31 +01:00
},
"gear_range": (range) => {
if (range) {
if (range== 'Cone Template') return 'Gabarit de cone';
}
return range;
},
"gear_ammo": (ammo) => {
if (ammo) {
if (ammo== 'Arrows/Bolts') return 'Flèches/Carreaux';
if (ammo== 'Canister Shot (Cannon)') return 'Cartouches (Canon)';
if (ammo== 'Shrapnel Shot (Cannon)') return 'Shrapnel (Canon)';
if (ammo== 'Solid Shot (Cannon)') return 'Solide (Canon)';
if (ammo== 'Bullets, Medium') return 'Balles, Moyenne';
if (ammo== 'Shotgun Shells') return 'Cartouche de Shotgun';
if (ammo== 'Laser Battery, Pistol') return 'Batterie pour laser, Pistolet';
if (ammo== 'Laser Battery, Rifle / SMG') return 'Batterie pour laser, Fusil';
}
return ammo;
},
2021-03-28 18:33:31 +02:00
"powers_duration": (duration) => {
if ( duration == 'One hour') return '1 heure';
if ( duration == 'Instant (slot); 5 (speed)') return 'Instantanée (apathie), 5 (vitesse)';
if ( duration == '(boost); Instant (lower)') return '5 (augmentation), Instantanée (diminution)';
if ( duration == 'Instant') return 'Instantannée';
if ( duration == 'Until the end of the victim\'s next turn') return 'Jusquà la fin du prochain tour de la victime';
2021-03-28 18:33:31 +02:00
if ( duration == 'A brief conversation of about five minutes') return 'Une brève conversation d\'environ 5 minutes';
if ( duration == '5 (detect), one hour (conceal)') return '5 (détection), 1 heure (dissimulation)';
if ( duration == 'Instant (Sound); 5 (Silence)') return 'Instantanée (son), 5 (silence)';
2021-03-28 18:33:31 +02:00
return duration;
},
"powers_range": (range) => {
if ( range == 'Smarts x5 (Sound); Smarts (Silence)')
return 'Intellect ×5 (son), Intellect (silence)';
2021-03-28 18:33:31 +02:00
if ( range == "Cone Template")
return "Gabarit de cône"
2021-03-28 18:33:31 +02:00
if ( range == "Touch")
return "Toucher"
if ( range == "Sm")
return "Intellect"
2021-03-28 18:33:31 +02:00
if ( range == "Sm x 2" || range == "Sm x2")
return "Intellect x2"
2021-03-28 18:33:31 +02:00
if ( range == "Self")
return "Personnel"
2021-03-28 18:33:31 +02:00
return range;
},
"powers_rank": (rank) => {
return swadeFrTranslator.getRank( rank)
}
2021-03-28 18:33:31 +02:00
} );
2021-03-15 09:22:27 +01:00
}
});
/************************************************************************************/
const transFolder = { "Actor": "Acteur", "Edges": "Atouts"}
const subFolder = { 'Social Edges': 'Atouts sociaux', 'Background Edges': 'Atouts de Background', 'Combat Edges': 'Atouts de combat',
'Leadership Edges': 'Atouts de commandement', 'Legendary Edges': 'Atouts légendaires', 'Power Edges': 'Atouts de pouvoir',
'Professional Edges': 'Atouts professionnels', 'Weird Edges': 'Atouts étranges', 'Edges': 'Atouts', 'Hindrances': 'Handicaps', 'Skills': 'Compétences',
'Equipment': 'Equipement', 'Ammo': 'Munitions', 'Armor': 'Armure', 'Common Gear': 'Matériel commun', 'Modern Firearms': 'Armes à feu modernes',
2021-03-28 18:58:41 +02:00
'Personal Weapons': 'Armes', 'Special Weapons': 'Armes spéciales', 'Bullet': 'Balles', 'Cannon': 'Canon', 'Laser Battery': 'Batterie Laser',
'Adventuring Gear': 'Matériel d\'aventure', 'Animals and Tack': 'Animaux', 'Clothing': 'Vêtements', 'Computers & Electronics':'Ordinateurs et Electroniques',
'Firearms Accessories': 'Accessoires armes à feu', 'Food': 'Nourriture', 'Personal Defense': 'Auto-défense', 'Futuristic': 'Futuriste',
2021-03-28 18:58:41 +02:00
'Medieval & Ancient': 'Médiévale et Antiquité', 'Modern': 'Moderne', 'Shields': 'Boucliers', 'Laser (Futuristic)': 'Laser (Fururiste)',
'Machine Guns': 'Mitraillettes', 'Pistols': 'Pistolets', 'Rifles': 'Fusils', 'Submachine Guns': 'Semi-automatiques', 'Cannons': 'Canons',
'Catapults': 'Catapultes', 'Flamethrowers': 'Lance-flammes', 'Rocket Launchers & Torpedoes': 'Lance roquettes et torpilles',
2021-03-28 18:58:41 +02:00
'Vehicular Weapons': 'Armes de véhicules' }
2022-02-06 19:07:10 +01:00
/* -------------------------------------------- */
// Register world usage statistics
function registerUsageCount( registerKey ) {
if ( game.user.isGM ) {
game.settings.register(registerKey, "world-key", {
name: "Unique world key",
scope: "world",
config: false,
default: "",
2022-02-06 19:07:10 +01:00
type: String
});
let worldKey = game.settings.get(registerKey, "world-key")
if ( worldKey == undefined || worldKey == "" ) {
worldKey = randomID(32)
game.settings.set(registerKey, "world-key", worldKey )
}
// Simple API counter
2022-02-19 09:30:35 +01:00
let regURL = `https://www.uberwald.me/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.data.version}"`
$.ajax(regURL)
2022-02-06 19:07:10 +01:00
/* -------------------------------------------- */
}
}
/************************************************************************************/
Hooks.once('ready', () => {
2022-02-05 00:23:39 +01:00
2022-02-06 17:48:39 +01:00
//FolderTranslate.translateFolders()
2022-04-29 15:30:12 +02:00
registerUsageCount("swade-fr-content")
2021-03-17 18:10:14 +01:00
});
2022-02-06 19:07:10 +01:00