balena-io / etcher

Flash OS images to SD cards & USB drives, safely and easily.
https://etcher.io/
Apache License 2.0
29.6k stars 2.1k forks source link

Replace Lodash templates #1810

Closed Shou closed 6 years ago

Shou commented 6 years ago

Instead we could simply use lambdas and native template literals, e.g.

const tplt = _.template('I am a <%= adjective %> template.')
tplt({ adjective: 'small' })

const tplt = ({ adjective }) => `I am a ${adjective} template.`
tplt({ adjective: 'small' })
lurch commented 6 years ago

Would this change have any knock-on effects if/when we decide to localize Etcher? ( #308 )

Shou commented 6 years ago

Can't see how, I don't believe _.template has any functionality that localization could leverage.

Edit: Ah, I see what you mean now. Because they're pure strings it would be possible to keep them in separate files and also without worrying about injection of other variables, assuming that could be dangerous.

lurch commented 6 years ago

Fair enough :) I just wondered if searching for _.template might be a useful way to find strings that ought to be localised, but thinking about it a bit more I guess there'll also be plenty of strings that we need to localise that aren't templated.

jhermsmeier commented 6 years ago

In terms of localization, string templates could be easily fitted with it by sticking a tag function in front of it (see tagged template literals), far easier than mending lodash templates.

urohit011 commented 6 years ago

I would like to work on this.