export const placeholderTokens = (text: string): Set => new Set(text.match(/\{[A-Za-z0-9_]+\}/g) ?? []); /** Tokens compared as sets: `missing` are in English but not `other`, `extra` the reverse. */ export function placeholderMismatch(english: string, other: string): { missing: string[]; extra: string[] } { const en = placeholderTokens(english); const ot = placeholderTokens(other); return { missing: [...en].filter((x) => !ot.has(x)).sort(), extra: [...ot].filter((x) => !en.has(x)).sort(), }; }