1
Create translation keys in the code
Import the
createInstance and InitOptions from the i18next library and add translation keys for all supported locales.translations.ts
2
Create email template
- Create a new file called
react-email-template.tsxand add the following code using components from the@react-email/componentslibrary. - Add the
renderEmailfunction to render the email template.
Here, we are using @react-email/components to build the email template. You can use any other library or bare HTML to build the email template.
Email template
Email template
react-email-template.tsx
3
Create the workflow and use translations
- Create the workflow definition by importing the
workflowfunction from the@novu/frameworklibrary. - Import the
renderEmailfunction from thereact-email-template.tsxfile. This is the email template that will be used to send the notification. - Import the
i18nfrom thetranslations.tsfile. - Import the
zodlibrary to validate the workflow payload.
workflow-with-translations.ts
4
Add workflow to serve function
api/novu/route.ts
5
Sync and test the workflow
- Sync the workflow to the Novu cloud.
- Test the workflow by triggering it to subscribers with different locales.