Skip to main content
Vuemail supports vue-i18n for internationalization. This guide shows how to convert an English Vuemail template to support multiple locales.

Prerequisites

To get the most out of this guide, you’ll need to:
This guide will use the following email template as a base.
emails/welcome.vue

Internationalization with vue-i18n

vue-i18n is the internationalization plugin for Vue, which provides a way to format messages in different languages.

1. Create messages for each locale

For each locale, create a new JSON file containing the content of the email in that locale.

2. Create the i18n instance

Create a function that creates an i18n instance for a locale, with all the messages:
emails/i18n.ts

3. Update the email template

In the email template, remove the hardcoded content and use the t function of useI18n() to format the email message strings.
emails/welcome.vue

4. Install vue-i18n when rendering

render renders each email with a new Vue application, so install vue-i18n on it, for the locale of the email, with the setupApp option:
Any component of your own that the email renders can call useI18n() too.

Previewing the emails

email dev renders emails with their PreviewProps, without setupApp, so it can’t install vue-i18n for emails that call useI18n(). To preview an email, have it create its own i18n instance for a locale prop instead, and use the t function of that instance:
emails/welcome.vue
Then pass the locale prop whenever you render the email, with no need for setupApp:
To keep emails away from vue-i18n altogether, see passing messages as props.