From a2618629a1fc928c5fc0b1d7265de689fe7c1e09 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 5 Feb 2022 00:23:39 +0100 Subject: [PATCH] Sync --- module/fr.json | 4 ++ module/module.json | 8 ++-- module/modules/swade-fr-init.js | 81 +++++++++++++++++++-------------- 3 files changed, 54 insertions(+), 39 deletions(-) diff --git a/module/fr.json b/module/fr.json index 0bfd1ef..9606781 100644 --- a/module/fr.json +++ b/module/fr.json @@ -56,6 +56,7 @@ "SWADE.Die": "Dé", "SWADE.WildDie": "Dé Joker", "SWADE.Mod": "Modificateur", + "SWADE.Modifier": "Modificateur", "SWADE.BenniesSpend": "Dépenser un Jeton", "SWADE.BenniesGive": "Donner un Jeton", "SWADE.BenniesRefresh": "Réinitialiser les Jetons", @@ -78,6 +79,7 @@ "SWADE.Weapons": "Armes", "SWADE.MeleeWeapons": "Armes de contact", "SWADE.RangedWeapons": "Armes à distance", + "SWADE.Range._name": "Portée", "SWADE.Armors": "Armures", "SWADE.Shields": "Boucliers", "SWADE.Biography": "Historique", @@ -100,6 +102,7 @@ "SWADE.HeartAttack": "Arrêt cardiaque", "SWADE.OnFire": "En feu", "SWADE.Poisoned": "Empoisonné", + "SWADE.Cover.Shield": "Couvert de bouclier", "SWADE.CoverShield": "Couvert de bouclier", "SWADE.Reach": "Allonge", "SWADE.Torch": "Torche", @@ -116,6 +119,7 @@ "SWADE.Mag": "Coups", "SWADE.Parry": "Parade", "SWADE.Cover": "Couvert", + "SWADE.Cover._name": "Couvert", "SWADE.Notes": "Notes", "SWADE.ActionsEffects": "Actions et Effets", "SWADE.Actions": "Actions", diff --git a/module/module.json b/module/module.json index fefa540..0b408e0 100644 --- a/module/module.json +++ b/module/module.json @@ -1,7 +1,7 @@ { "name": "swade-fr", "title": "SWADE Core Rules en Français - *NON-OFFICIEL*", - "description": "Traduction française du système SWADE

*** Join the official Discord server: Official Discord

*** Rejoignez la communauté Francophone: Francophone Discord

", + "description": "Traduction française du système SWADE

*** Join the official Discord server: Official Discord

*** Rejoignez la communauté Francophone: Francophone Discord

", "author": "Team Swade, La Fonderie", "authors": [ { @@ -42,9 +42,9 @@ ], "url": "https://gitlab.com/sasmira/swade-fr", "flags": {}, - "version": "0.18.4.2", + "version": "0.19.0.0", "minimumCoreVersion": "0.8.0", - "compatibleCoreVersion": "1.0.0", + "compatibleCoreVersion": "9", "scripts": [], "esmodules": [ "modules/swade-fr-init.js" @@ -83,4 +83,4 @@ "protected": false, "coreTranslation": false, "library": false -} +} \ No newline at end of file diff --git a/module/modules/swade-fr-init.js b/module/modules/swade-fr-init.js index dfdfeba..50d76bd 100644 --- a/module/modules/swade-fr-init.js +++ b/module/modules/swade-fr-init.js @@ -1,4 +1,48 @@ +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' }, + {source: 'World War II Military Aircraft', translation: 'Avions Militaires Seconde Guerre Mondiale' }, + ] + } +] + +class FolderTranslate { + + static async translateFolders() { + + for (let tData of __compFolderTranslation) { + let pack = game.packs.get(tData.compendium); + let wasLocked = false; + if (pack.locked) { + pack.configure({locked: false}) + 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) { + pack.configure({locked: true}) + } + } + } +} + +/************************************************************************************/ +Hooks.once('translateCompendiumFolders', () => { + console.log("LOADED !!!!!!") +}); + /************************************************************************************/ Hooks.once('init', () => { @@ -91,42 +135,9 @@ const subFolder = { 'Social Edges': 'Atouts sociaux', 'Background Edges': 'Atout 'Catapults': 'Catapultes', 'Flamethrowers': 'Lance-flammes', 'Rocket Launchers & Torpedoes': 'Lance roquettes et torpilles', 'Vehicular Weapons': 'Armes de véhicules' } -/************************************************************************************/ -const __translate_sub_folders = async (packName) => { - let pack = game.packs.get(packName) - pack.locked = false; - let folderEntityIds = pack.index.filter(x => x.name === "#[CF_tempEntity]"); - for ( let index of folderEntityIds) { - let folderEntity = await pack.getEntity(index._id); - //console.log("Fold1", folderEntity); - let newName = subFolder[folderEntity.data.flags.cf.name]; - if ( newName) { - await pack.updateEntity({ _id: index._id, 'flags.cf.name': newName } ); - } - } -} - -/************************************************************************************/ -const __fix_folder_names = async ( ) => { - if ( game.customFolders.compendium.folders ) { - for ( let [key, trans] in transFolder) { - for ( let folder of game.customFolders.compendium.folders.entries) { - folder.name = trans; - folder.save(false); - } - } - } - - __translate_sub_folders("swade-core-rules.swade-edges"); - __translate_sub_folders("swade-core-rules.swade-hindrances"); - __translate_sub_folders("swade-core-rules.swade-equipment"); - -} - /************************************************************************************/ Hooks.once('ready', () => { - //if (game.user.isGM) { - //setTimeout( __fix_folder_names, 4000, true, false); - //} + + FolderTranslate.translateFolders() });