Skip to content

Commit

Permalink
Merge pull request #388 from allnnde/crowdin
Browse files Browse the repository at this point in the history
Crowdin
  • Loading branch information
allnnde authored Jan 25, 2025
2 parents 4b969fc + f4e0856 commit 9a1319a
Show file tree
Hide file tree
Showing 17 changed files with 6,712 additions and 233 deletions.
7 changes: 5 additions & 2 deletions src/babele-register.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function AACreateItemNameProxy(item, realName) {
}

Hooks.once("init", () => {
if (typeof Babele !== "undefined") {
if (game.babele) {
game.settings.register("pf2e-es", "dual-language-names", {
name: "Nombres en español e ingles",
hint: "No solo muestra los nombres en español sino tambien en ingles.",
Expand Down Expand Up @@ -91,6 +91,9 @@ Hooks.once("init", () => {
translateActorItems: (data, translation) => {
return game.langEsPf2e.translateItems(data, translation, true);
},
translateAdventureActors: (data, translation) => {
return game.langEsPf2e.translateArrayOfObjects(data, translation, "adventureActor");
},
translateAdventureItems: (data, translation) => {
return game.langEsPf2e.translateItems(data, translation, false, false);
},
Expand Down Expand Up @@ -164,7 +167,7 @@ Hooks.once("init", () => {
});

Hooks.once("i18nInit", () => {
if (game.i18n.lang === "es") {
if (game.i18n.lang === "de") {
const fallback = game.i18n._fallback;
removeMismatchingTypes(fallback, game.i18n.translations);
}
Expand Down
1,864 changes: 1,825 additions & 39 deletions src/helper/pack-extractor/constants.js

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions src/helper/pack-extractor/pack-extractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,12 @@ export function extractEntry(entry, mapping, itemDatabase = {}, nestedEntryType
continue;
}
// Apply special extraction rules on value level
// Special extraction for actors
if (["adventureActors", "adventureCompendiumActors"].includes(nestedEntryType)) {
// Add the actor id in order to identify actor duplicates (e.g. treasure actors with the same name)
extractedEntryData.extractedEntry.duplicateId = entry._id;
}

// Special extraction for actor items
if (["actorItems", "adventureActorItems"].includes(nestedEntryType)) {
const formatedActorItem = formatActorItem(
Expand Down Expand Up @@ -773,14 +779,14 @@ function unifyLineBreaks(htmlString) {
*/
function getCompendiumLinkFromItemData(item) {
let compendiumLink = false;
if (resolvePath(item, "flags.core.sourceId").exists) {
if (resolvePath(item, "flags.core.sourceId").exists && item.flags.core.sourceId !== null) {
compendiumLink = item.flags.core.sourceId;
}
if (resolvePath(item, "_stats.compendiumSource").exists) {
if (resolvePath(item, "_stats.compendiumSource").exists && item._stats.compendiumSource !== null) {
compendiumLink = item._stats.compendiumSource;
}

if (compendiumLink !== null && compendiumLink.startsWith("Compendium.pf2e.")) {
if (compendiumLink !== false && compendiumLink.startsWith("Compendium.pf2e.")) {
return compendiumLink;
}

Expand Down
140 changes: 139 additions & 1 deletion src/pack-extractor/pack-extractor-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@
"abomination-vaults-bestiary",
"age-of-ashes-bestiary",
"agents-of-edgewatch-bestiary",
"blood-lords-bestiary",
"book-of-the-dead-bestiary",
"crown-of-the-kobold-king-bestiary",
"extinction-curse-bestiary",
"fall-of-plaguestone",
"fists-of-the-ruby-phoenix-bestiary",
"gatewalkers-bestiary",
"hazards",
"highhelm-bestiary",
Expand All @@ -65,19 +68,154 @@
"outlaws-of-alkenstar-bestiary",
"paizo-pregens",
"pathfinder-dark-archive",
"quest-for-the-frozen-flame-bestiary",
"rage-of-elements-bestiary",
"rusthenge-bestiary",
"season-of-ghosts-bestiary",
"seven-dooms-for-sandpoint-bestiary",
"shadows-at-sundown-bestiary",
"sky-kings-tomb-bestiary",
"strength-of-thousands-bestiary",
"the-enmity-cycle-bestiary",
"the-slithering-bestiary",
"travel-guide-bestiary",
"troubles-in-otari-bestiary",
"vehicles"
],
"mapping": "actor",
"savePath": "crowdin"
"savePath": "crowdin",
"limitedPacks": {
"blood-lords-bestiary": [
"Arboreal Snag",
"Azmakian Effigy",
"Bloodshroud",
"Charghar",
"Chattering Jaws",
"Cobblebone Swarm",
"Creeping Crone",
"Floating Femur",
"Ghostly Mob",
"Ghoul Antipaladin",
"Ghoul Razorclaw",
"Grave Hag",
"Necrohulk Flailer",
"Necrohulk Smasher",
"Necromunculus",
"Phalanx of Phalanges",
"Pyrogeist",
"Rust Hag",
"Scrabbling Ribcage",
"Shadowforged Guardian",
"Skull Fairy",
"Tombstone Troll",
"Virulak Necromancer",
"Virulak Villager"
],
"extinction-curse-bestiary": [
"Ammut",
"Ararda",
"Aukashungi Swarm",
"Bogey",
"Bogeyman",
"Bone Croupier",
"Brughadatch",
"Bugaboo",
"Bugul Noz",
"Cat Sith",
"Chimpanzee Visitant",
"Counteflora",
"Cu Sith",
"Deghuun (Child of Mhar)",
"Doblagub",
"Faceless Butcher",
"Flea Swarm",
"Gahlepod",
"Giant Aukashungi",
"Giant Flea",
"Harrow Doll",
"Iffdahsil",
"Iridescent Elephant",
"Lion Visitant",
"Luminous Ooze",
"Mechanical Carny",
"Muse Phantom",
"Muurfeli",
"Obsidian Golem",
"Qurashith",
"Saurian Warmonger",
"Saurian Worldwatcher",
"Shoony Hierarch",
"Shoony Militia Member",
"Shoony Tiller",
"Tallow Ooze",
"Urdefhan Dominator",
"Urdefhan High Tormentor",
"Urdefhan Hunter",
"Vavakia",
"Vermlek",
"Viskithrel",
"Vitalia",
"Xilvirek",
"Xulgath Bilebearer",
"Xulgath Deepmouth",
"Xulgath Gutrager",
"Xulgath Spinesnapper",
"Xulgath Stoneliege",
"Xulgath Thoughtmaw",
"Yaganty",
"Zuipnyrn"
],
"fists-of-the-ruby-phoenix-bestiary": [
"Anugobu Apprentice",
"Anugobu Wondercrafter",
"Berberoka",
"Canopy Elder",
"Caustic Monitor",
"Rivka (Cimurlian)",
"Rivka (Igroon)",
"Rivka (Kujiba)",
"Rivka (Mogaru)",
"Rivka (Yorak)",
"Sanzuwu",
"Spirit Turtle",
"Sthira"
],
"quest-for-the-frozen-flame-bestiary": [
"Arboreal Tar Tree",
"Beaver",
"Castoroides",
"Giant Tapir",
"Glyptodon",
"Groplit",
"Lagofir",
"Long-horned Bison",
"Rime Sludge",
"Roru",
"Tar Ooze"
],
"season-of-ghosts-bestiary": [
"Akashti",
"Argyrzei",
"Guhdggi",
"Ijda",
"Kagekuma",
"Meokdan",
"Shisagishin",
"Sojiruh"
],
"strength-of-thousands-bestiary": [
"Anadi Fateweaver",
"Anadi Lurker",
"Anadi Seeker",
"Giant Mining Bee",
"Giant Silverfish",
"Giant Worker Bee",
"Gluttonworm",
"Screaming Sulfur",
"Silverfish Swarm",
"Sunburst Corpse"
]
}
},
"Journals": {
"packNames": ["criticaldeck", "journals"],
Expand Down
14 changes: 13 additions & 1 deletion src/translator/translator-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,23 @@
"spellVariants": { "path": "system.overlays", "converter": "translateSpellVariant" },
"target": "system.target.value",
"time": { "path": "system.time.value", "converter": "translateTime" },
"trainedLore": "system.trainedSkills.lore"
"trainedLore": "system.trainedSkills.lore",
"unidentifiedName": "system.identification.unidentified.name"
}
},
"skillSpecial": { "entryType": "Actor", "mappingEntries": { "label": "label" } },
"tile": { "entryType": "Scene", "mappingEntries": { "texture": "texture.src" } },
"adventureActor": {
"entryType": "Actor",
"mappingEntries": {
"name": "name",
"acDetails": "system.attributes.ac.details",
"blurb": "system.details.blurb",
"sourceId": "flags.core.sourceId",
"tokenName": { "path": "prototypeToken.name", "converter": "translateTokenName" },
"items": { "path": "items", "converter": "translateAdventureActorItems" }
}
},
"adventureJournal": {
"entryType": "JournalEntry",
"mappingEntries": {
Expand Down
36 changes: 29 additions & 7 deletions src/translator/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class Translator {

// Initialize translator
async initialize() {
this.artworkExceptions = {};
// Read config file
const config = await Promise.all([
fetch("modules/pf2e-es/src/translator/translator-config.json")
Expand Down Expand Up @@ -309,16 +308,18 @@ class Translator {
let itemName = entry.name;

// For compendium items, get the data from the compendium

const compendiumLink = getCompendiumLinkFromItemData(entry);
if (
entry.flags?.core?.sourceId &&
entry.flags.core.sourceId.startsWith("Compendium.pf2e.") &&
!entry.flags.core.sourceId.includes(".Actor.") &&
!this.itemBlacklist.includes(entry.flags.core.sourceId)
compendiumLink &&
compendiumLink.startsWith("Compendium.pf2e.") &&
!compendiumLink.includes(".Actor.") &&
!this.itemBlacklist.includes(compendiumLink)
) {
// Get the actual compendium name
const itemCompendium = entry.flags.core.sourceId.split(".");
const itemCompendium = compendiumLink.split(".");

const originalName = fromUuidSync(entry.flags.core.sourceId)?.flags?.babele?.originalName;
const originalName = fromUuidSync(compendiumLink)?.flags?.babele?.originalName;
if (originalName) {
entry.name = originalName;
itemName = originalName;
Expand Down Expand Up @@ -495,4 +496,25 @@ class Translator {
}
return value;
}
}

/**
* Extracts an item's compendium link for items, that originate from a compendium
*
* @param {Object} item Item data
* @returns {string|boolean} The item's compendium link
*/
function getCompendiumLinkFromItemData(item) {
let compendiumLink = false;
if (item.flags?.core?.sourceId && item.flags.core.sourceId !== null) {
compendiumLink = item.flags.core.sourceId;
}
if (item._stats?.compendiumSource && item._stats.compendiumSource !== null) {
compendiumLink = item._stats.compendiumSource;
}
if (compendiumLink !== false && compendiumLink.startsWith("Compendium.pf2e.")) {
return compendiumLink;
}

return false;
}
Loading

0 comments on commit 9a1319a

Please sign in to comment.