bigBear713 / nb-trans

an angular(2+) component about i18n.
https://bigbear713.github.io/nb-trans/
MIT License
49 stars 6 forks source link

Can use the lodash's template() function to handle the translated string #48

Open bigBear713 opened 1 year ago

bigBear713 commented 1 year ago

version: v16.0.0 The lib support the template with params, like This is a {{param1}}, and the {{param1}} with be replaced as param value.

Now it is handled by RegExp, it is ok now, but it's a bit complicated. I think we can simplify the process, using a third-party lib to do it.

The lodash you know is a powful third-party lib, and provide template() to handle template string. I think we can try to use it to help us to handle the translated string, we only need to provide the translated string and params value. It can make the process be more simple.

Of course, it's not always the best way, so try it and discuss it