UNPKG

@neiderruiz/translate-files

Version:

Internationalize and manage your website easily with (CSV or JSON to i18n)

11 lines (9 loc) 305 B
export const extractKeysAndTexts = (content: string): Record<string, string> => { const regex = /{{(.*?)(?:\|)(.*?)}}/g; let match; const result: Record<string, string> = {}; while ((match = regex.exec(content)) !== null) { result[match[1]] = match[2]; } return result; }