forwardemail / email-templates

Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for @forwardemail, @ladjs, @cabinjs, @spamscanner, and @breejs.
https://forwardemail.net/docs/send-emails-with-node-js-javascript
MIT License
3.67k stars 337 forks source link

Have you considered using globalize for better i18n? #349

Closed ieugen closed 5 years ago

ieugen commented 5 years ago

Hi,

I think you've built a very nice piece of software and we are using it in one of our services. I've taken the time to give some feedback from our use case.

We send emails that are translated in several languages. Some of them have translations in different folders.

We can't use the i18n implementation provided by email-templates and we are hacking around it because it has a single instance. Once created, we can't say - for this email, load translations from this other folder .

Other things to consider: i81n-node has not been updated since 2016 and seems to be gathering issues.

On the other hand Globalize implements proper i18n support based on ICU - which IMO is a great library and "standard" to work with. It provides everything you need to do proper internationalization. We use it with 16 languages and we had no issues with it.

Globalize does not take care of file loading so it is plugable in that way. You can load files however you want.

You can also create as many instances as you wish.

I hope you find this feedback helpful.

https://github.com/globalizejs/globalize

niftylettuce commented 5 years ago

My implementation of i18n is with respect to simplicity and ease of use in my framework https://lad.js.org. The i18n package we use actually is in the Lad org and you can read about it here https://github.com/ladjs/i18n. We also use mandarin under the hood https://github.com/niftylettuce/mandarin.

niftylettuce commented 5 years ago

@ieugen If you want to reload files after change, see https://github.com/ladjs/i18n/blob/master/src/index.js#L28-L30.

I think that if you're adding a new JSON file (e.g. a completely new locale), then it'd be pretty simple to just gracefully reload the worker threads in your process. In my opinion and based on my experience, it is VERY bad behavior to have a production process that watches/changes dynamically based off other files/directories.