(html: string, translations: Map<string, string>)
| 16 | // Rewrites all text elements to a new locale. No browser, no preview. |
| 17 | |
| 18 | export async function localize(html: string, translations: Map<string, string>): Promise<string> { |
| 19 | const comp = await openComposition(html); |
| 20 | |
| 21 | const textElements = comp.find({ tag: "div" }); |
| 22 | |
| 23 | comp.batch(() => { |
| 24 | for (const id of textElements) { |
| 25 | const el = comp.getElement(id); |
| 26 | if (!el?.text) continue; |
| 27 | const translated = translations.get(el.text); |
| 28 | if (translated) comp.setText(id, translated); |
| 29 | } |
| 30 | }); |
| 31 | |
| 32 | return comp.serialize(); |
| 33 | } |
| 34 | |
| 35 | // ── Brand restyle agent ─────────────────────────────────────────────────────── |
| 36 | // Apply brand colors to all elements with a matching class name. |
nothing calls this directly
no test coverage detected