import { getPayload } from 'payload' import configPromise from '../src/payload.config' async function run() { const payload = await getPayload({ config: configPromise }) const pages = await payload.find({ collection: 'pages', limit: 100, locale: 'pl' }) for (const page of pages.docs) { if (!['faq', 'kontakt', 'stowarzyszenie', 'polityka-prywatnosci', 'polityka-cookies', 'impressum'].includes(page.slug || '')) continue; for (const loc of ['en', 'de'] as const) { const dbPage = await payload.findByID({ collection: 'pages', id: page.id, locale: loc }) if (!dbPage || !dbPage.layout) continue; let modified = false; const layout = dbPage.layout.map((block: any) => { // preserve IDs for (const key of Object.keys(block)) { if (block[key] && typeof block[key] === 'object' && block[key].id !== undefined) { block[key] = block[key].id } } if (block.blockType === 'contactInfo') { block.hours = loc === 'en' ? "Mon-Fri: 9:00 - 17:00\nBy appointment" : "Mo-Fr: 9:00 - 17:00\nNach Vereinbarung" block.address = "TO BE CONFIRMED BY CLIENT" modified = true; } if (block.blockType === 'TextSection') { block.text = loc === 'en' ? "Content in preparation" : "Inhalt in Vorbereitung" modified = true; } return block; }); if (modified) { await payload.update({ collection: 'pages', id: page.id, locale: loc, data: { layout } }) console.log(`Fully translated ${page.slug} to ${loc}`) } } } process.exit(0) } run().catch(console.error)