Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

pass object literal from function into json array

$
0
0

I have a javascript function from creating localized strings as follows...

let strings = new LocalizedStrings({
 en:{
   sites:"Sites",
   addSite:"Add a new site",
   online:"Online"
 },
 it: {
    sites:"Siti",
   addSite:"Aggiungi un nuovo sito",
   online:"in linea"
 }
});

I use this in my page like this..

<p>
  {strings.sites}
</p>

My question is how do I pass this into my JSON because I need to update the column headings in my table which uses JSON to define this (see the 'name' heading)...

const columns = [
    {
        name: 'Id',
        selector: 'id',
        sortable: true,
        hide: 6000,
    },
    {
        name: '{strings.online}',
        selector: 'cloudAccessEnabled',
        sortable: true,
        minWidth: '10px',
        center: true,
        cell: row => (
            <MDBIcon icon="circle"
                className={row.cloudAccessEnabled === true ? 'green-text' : 'red-text'} />
        )
    },

Viewing all articles
Browse latest Browse all 138163

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>