Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 3x 37x 44x 35x 9x 37x | import { type Locale } from "./interface";
export type FlatLocale = Record<string, string>;
/**
* 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;
};
|