import type { Locale } from "./interface"; export type FlatLocale = Record; /** * Turns a nested locale object into a flat locale object. */ export const flattenLocale = ( locale: Locale, flatLocale: FlatLocale = {}, prefix = "" ): FlatLocale => { for (const [key, value] of Object.entries(locale)) { if (typeof value === "string") { flatLocale[prefix + key] = value; } else { flattenLocale(value, flatLocale, prefix + key + "."); } } return flatLocale; };