I have a variable that translates dynamically based on the selected language of the user. I am trying to replace the text for the column headers of the excel file being downloaded but I cannot get the correct format where in I can replace the hardcoded headers text with my variable. Can anyone help me with this? Thanks!
Here’s the return inside my json to excel function
var newJson = this.props.users_list.map(function (obj) {
return {
"Name": /^[-@=+]/.test(obj.name) ? "\'" + obj.name : obj.name,
"Contact": /^[-@=+]/.test(obj.contact) ? "\'" + obj.contact : obj.contact,
....
}
}
I want to replace the headers “Name” and “Contact” here with the variable lang.name and lang.contact which are declared like this after my imports:
const toolLanguage = {
name: "Name",
contact: "Contact"
};
const lang = Utilities.translateLang(toolLanguage);
I’ve tried these formats but I’m only getting typing errors:
lang.name : /^[-@=+]/.test(obj.name) ? "\'" + obj.name : obj.name,
lang.contact : /^[-@=+]/.test(obj.contact) ? "\'" + obj.contact : obj.contact,
{lang.name} : /^[-@=+]/.test(obj.name) ? "\'" + obj.name : obj.name,
{lang.contact} : /^[-@=+]/.test(obj.contact) ?