Files
project-afterlife/scripts/localize-to-es.js
consultoria-as 449c02eadc
Some checks failed
Deploy Multi-VM / Deploy VM Web (push) Has been cancelled
Deploy Multi-VM / Deploy VM Auth (push) Has been cancelled
Deploy Multi-VM / Deploy Game Servers (docker-compose.fusionfall.yml, VM_FUSIONFALL_HOST, VM_FUSIONFALL_SSH_KEY, VM_FUSIONFALL_USER, fusionfall) (push) Has been cancelled
Deploy Multi-VM / Deploy Game Servers (docker-compose.maple2.yml, VM_MAPLE2_HOST, VM_MAPLE2_SSH_KEY, VM_MAPLE2_USER, maple2) (push) Has been cancelled
Deploy Multi-VM / Deploy Game Servers (docker-compose.minecraft.yml, VM_MINECRAFT_HOST, VM_MINECRAFT_SSH_KEY, VM_MINECRAFT_USER, minecraft) (push) Has been cancelled
Deploy Multi-VM / Deploy Game Servers (docker-compose.retro.yml, VM_RETRO_HOST, VM_RETRO_SSH_KEY, VM_RETRO_USER, retro) (push) Has been cancelled
feat: phase 3 redesign, game images, auth system, vm guides, service isolation
- Redesign all internal pages to warm/gold aesthetic (catalog, game detail,
  documentary, about, donate, community, guides, contact, server-status,
  login, profile, admin, not-found)
- Add real cover images for all 4 games via Strapi CMS with getImageUrl helper
- Integrate NextAuth v5 with Authentik OIDC authentication
- Add new public pages: community, guides, contact, server-status
- Add new protected pages: login, profile, admin dashboard
- Remove legacy AFC/MercadoPago system entirely
- Add Docker Compose split files for service isolation (main, auth, fusionfall, nier)
- Add OpenFusion VM deployment configs (config.vm.ini, systemd service, README-VM)
- Add NieR Reincarnation server guide and desktop client guide
- Add architecture docs for multi-VM deployment
- Add healthcheck, SSE, contact, newsletter, admin API routes
- Add reusable UI components, skeleton loaders, activity feed, bookmark system
- Update deployment and game server documentation
2026-04-28 05:15:38 +00:00

88 lines
2.4 KiB
JavaScript

#!/usr/bin/env node
/**
* Create Spanish (es) localizations for all English (en) content in Strapi
*/
const STRAPI_URL = process.env.STRAPI_URL || "http://localhost:1337";
async function apiRequest(endpoint, method = "GET", body = null) {
const url = `${STRAPI_URL}/api${endpoint}`;
const options = {
method,
headers: { "Content-Type": "application/json" },
...(body ? { body: JSON.stringify(body) } : {}),
};
const response = await fetch(url, options);
const data = await response.json().catch(() => null);
if (!response.ok) {
throw new Error(`${response.status}: ${JSON.stringify(data)}`);
}
return data;
}
async function getAllEnDocuments(path) {
const res = await apiRequest(`${path}?pagination[pageSize]=200&locale=en`);
const items = res.data || [];
// Deduplicate by documentId
const seen = new Set();
return items.filter((item) => {
if (seen.has(item.documentId)) return false;
seen.add(item.documentId);
return true;
});
}
async function createEsLocalization(path, documentId, data) {
return apiRequest(`${path}/${documentId}?locale=es`, "PUT", { data });
}
async function main() {
console.log("🌐 Creating Spanish localizations...\n");
// 1. Documentaries
console.log("📽️ Documentaries:");
const docs = await getAllEnDocuments("/documentaries");
for (const doc of docs) {
try {
await createEsLocalization("/documentaries", doc.documentId, {
title: doc.title,
description: doc.description,
});
console.log(`${doc.title}`);
} catch (err) {
if (err.message.includes("already exists")) {
console.log(` ⚠️ Already has es: ${doc.title}`);
} else {
console.log(`${doc.title}: ${err.message}`);
}
}
}
// 2. Chapters
console.log("\n📖 Chapters:");
const chapters = await getAllEnDocuments("/chapters");
for (const ch of chapters) {
try {
await createEsLocalization("/chapters", ch.documentId, {
title: ch.title,
content: ch.content,
order: ch.order,
});
console.log(`${ch.title}`);
} catch (err) {
if (err.message.includes("already exists")) {
console.log(` ⚠️ Already has es: ${ch.title}`);
} else {
console.log(`${ch.title}: ${err.message}`);
}
}
}
console.log("\n✨ Done!");
}
main().catch((err) => {
console.error("💥 Fatal error:", err.message);
process.exit(1);
});