I am interested in utilizing ES6 template strings as templates for translating content within my Node.js application.
For example, I have a JSON file named en_GB.json
with the following structure:
{
"app.template": "This is ${foo} I ${bar}",
"app.foo": "bar"
}
In my Node.js code, I perform the following actions:
const translations = require('./en_GB.json')
const foo = 'what'
const bar = 'want'
console.log(translations['app.template']) // Outputs This is ${foo} I ${bar}
The desired output I want to achieve is "This is what I want"
Is there a way to accomplish this without resorting to using a helper function?