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

pug i18n issue #260

Closed claylua closed 6 years ago

claylua commented 6 years ago

Hi niftylettuce!

Thanks for writing such awesome library! I was trying to use it but i face an issue here with i18n and pug. Assuming this is the pug text i have

 p= t(`Reason: ${result.error}`)

How do i go about separating the text "Reason: " and the variable ${result.error} in pug? I tried doing the following

p= t(`Reason: %s`, ${result.error})

but as we both know, it will fail with unknown syntax. The reason being is that the auto generated locales folder files will have the variable result.error text in it which i would like to avoid to properly translate each text in the email.

Hope to hear from you too! Thanks for the hard work!

OmgImAlexis commented 6 years ago

Could you not use something like this?

p #{t(`Reason:`)} #{result.error}
claylua commented 6 years ago

@OmgImAlexis Thanks for the quick response! It does work with a little bit of modification to suit the formatting on email-templates library, i got this to work using your example,

p `${t(`Reason:`)} ${result.error}`

hope this helps someone else out there using this library! Thanks @OmgImAlexis again!