/** Window event that keeps every ML control on one active locale. */ export const ML_LOCALE_CHANGE = 'summer:ml-locale' /** Broadcast the locale the administrator selected on any ML control. */ export function broadcastMLLocale(locale: string): void { if (typeof window === 'undefined' || locale === '') { return } window.dispatchEvent(new CustomEvent(ML_LOCALE_CHANGE, { detail: locale })) } /** Locale → text map as it is sent on save: only string values. */ export function localeRecord(value: unknown): Record { const out: Record = {} if (value === null || typeof value !== 'object' || Array.isArray(value)) { return out } for (const [locale, text] of Object.entries(value as Record)) { if (typeof text === 'string') { out[locale] = text } } return out }