I have to work around the limitation of gettext
to recognise ES6 template strings, and I thought about getting the "non interpolated value" of the template strings as a compilation step, in order to have only "normal" strings in the code.
Basically what I would like to achieve is transform this
const adjective = 'wonderful'
const something = `Look, I am a ${adjective} string`
console.log(something)
> "Look, I am a wonderful string"
into this
const adjective = 'wonderful'
const something = 'Look, I am a ${adjective} string'
console.log(something)
> "Look, I am a ${adjective} string"
One brutal way of achieving this is using sed
, but it's most certainly not the more elegant (and probably also error prone)
sed "s/\`/'/g" FILENAME
Any better and cleaner idea comes to mind?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With