Closed AnToHu0 closed 2 years ago
For number formatting see https://www.npmjs.com/package/@lightspeed/i18n-number-format or https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat. For the former, you'd have to pass this as a function to locals
variable.
For date formatting see https://day.js.org/docs/en/durations/locale. You'd have to provide a locals
variable of dayjs
that has all these plugins enabled and locales you support already require'd.
There's also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString which works in Node.js too.
Reference the README at https://github.com/forwardemail/email-templates to see what locals
is and how to use it. You can define a global locals which will be inherited, or only do it for specific emails.
Many of I18n realisations has formatting syntax like
t('intlNumber', { val: product.price})
to format number like 8990 to 8 990. Also like currency and date formatting tools. So is there any possibility to use such formatters with this package?