Open this example in the interactive library
Source code
const rows = [
{ key: "home", en: "Home", fr: "Accueil" },
{ key: "save", en: "Save", fr: "Enregistrer" },
{ key: "help", en: "Help", fr: "" },
];
const result = Object.fromEntries(rows.map((r) => [r.key, r.fr || r.en]));
console.log(JSON.stringify(result, null, 2));
Sample output
{
"home": "Accueil",
"save": "Enregistrer",
"help": "Help"
}