Closed claylua closed 6 years ago
You need to use backticks instead of double quotes when you're using ${}
.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
For example.
var text = `${time} ${t('seconds')}`;
@OmgImAlexis thanks for the super quick response! apparently using backticks will evaluate ${} but it will throw the following exception
ReferenceError: t is not defined
since t()
is only available in pug under this library. But without this, email-templates
library won't translate the text. any thoughts?
t
is available through https://github.com/ladjs/i18n - does that solve your issue @claylua ?
I also have a question on this, is it possible to render i18n without sending email, e.g. just by using email.render?
@Freundschaft Thank you for the comment! I had overlooked this when I was crafting the API methods. I've now moved all the logic for localization/i18n from the send
method to the render
method. It should work as you'd expect now! You can now render i18n without sending an email simply by using email.render
as you suggested. Please try v3.3.1 available on npm now:
npm install email-templates@latest
or with yarn:
yarn add email-templates@latest
cc @claylua
thanks a lot!
Hi Guys,
It's me again. And with another issue that i faced. Assuming i have a text variable on nodejs as follow,
now, i'll sent an email like this
now with the pug like below
everything works fine, other than the 'seconds' here in the locals 'time' doesn't translate to another language.
i tried the following on nodejs code
but the email i receive would be
now, the reason why i need these to be in the variable is because there are days, minutes, hours and seconds. These keywords are placed on nodejs rather than pug and i'm trying to find ways to separate these keywords so that it also translate normally like other text in pug.
any ways to make the text in each variable translate or workaround for such issue? Thanks!