UNPKG

@neiderruiz/translate-files

Version:

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

16 lines (14 loc) 417 B
import { ObjectWithStringKeys } from "../types/types"; export const addKeyValueToObject = ( object: ObjectWithStringKeys, keys: string[], value: string ) => { const [currentKey, ...remainingKeys] = keys; if (remainingKeys.length === 0) { object[currentKey] = value; } else { object[currentKey] = object[currentKey] || {}; addKeyValueToObject(object[currentKey], remainingKeys, value); } };