> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/emails/templates/translate.md).

# Translate a template

Translate an email template — add a language and give it a subject and a body.

**Where:** Email → Templates → a template → **Translations** · `/projects/<project>/emails/templates/<templateId>/edit`

One template holds one translation per language. Each recipient gets their own language when it is a project language, else the project default — see [Message templates](/codemash/cloud/concepts/message-templates.md). A template that misses a project language is marked **Missing de** in the list and is refused by campaigns and triggers (`CM-ERRORS-LANGUAGES-004`).

## Before you start

* The language must be a project language: add it in [Project → Settings → Languages](/codemash/cloud/project/settings/languages.md). The tags in the editor show only project languages.
* Permission `email:update`.

## Steps

1. In **Email → Templates**, find the template with the amber badge, for example **Order shipped — Missing de**, and open it.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-000eaeb4e48be09174bdc928018bee266a1f8916%2Ftemplates-translate-1.png?alt=media" alt="Email Templates list: Order shipped with the badge Missing de"><figcaption><p>A template without the German translation.</p></figcaption></figure>
2. Under **Translations**, the tags show the project languages: **EN (default)** is picked (highlighted), **DE** is not.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-fb6671c72152b4463bef20676bc08e9905cea87d%2Ftemplates-translate-2.png?alt=media" alt="Edit Email Template Order shipped: Translations tags EN (default) highlighted and DE not"><figcaption><p>Only English is picked.</p></figcaption></figure>
3. Press **DE**. A new block for **German de** is added under the English one. Fill **Subject** (`Ihre Bestellung ist unterwegs`) and change the **Template** body to the German text.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-a681729bfd49221ab38f1dd2b79b500ec2eb141d%2Ftemplates-translate-3.png?alt=media" alt="The German block: Language German de, Subject Ihre Bestellung ist unterwegs, under the English body"><figcaption><p>The new German block.</p></figcaption></figure>

   <div data-gb-custom-block data-tag="hint" data-style="warning" class="hint hint-warning"><p><strong>Edit the body of the new block.</strong> The new block shows the default MJML, but until you change it the body counts as empty: <strong>Update</strong> then does nothing and shows no message. Paste or type the translated body before you press <strong>Update</strong>.</p></div>
4. Press **Update**.

## Result

You are back on the list, and the template has no **Missing de** badge any more. Campaigns and triggers can use it again; German-speaking recipients get the German subject and body.

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-af48e1245008d33062c317275c5543d9a7cb5bdf%2Ftemplates-delete-3.png?alt=media" alt="Email Templates list: Order shipped without a badge"><figcaption><p>The template now covers every project language.</p></figcaption></figure>

## Change or remove it later

* **Change a translation** — edit its **Subject** or body and press **Update**.
* **Remove a translation** — press the bin icon at the bottom of its block (or the language tag again), then **Update**. Removing a project language brings the **Missing** badge back.
* Extra languages that are not project languages are allowed and never used.

## Do it from code

Send the whole template back with every translation you want to keep:

```ts
const { item } = await norbix.hub.notifications.getEmailTemplate({ id: viewId });
await norbix.hub.notifications.updateEmailTemplate({
  viewId,
  templateName: item.templateName,
  communicationChannel: item.communicationChannel,
  translations: [
    ...item.translations,
    { language: 'lt', content: { subject: 'Jūsų paskyra užrakinta', body: { code: '<mjml><mj-body><mj-section><mj-column><mj-text>Labas, @Model.Recipient.FirstName.</mj-text></mj-column></mj-section></mj-body></mjml>' } } },
  ],
});
// read back: translations en, de, lt
```

```sh
TR=$(norbix hub notifications email template get --id tmpl_77HajPbb0ijj4ij0uQTMNF --json | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>console.log(JSON.stringify(JSON.parse(s).item.translations)))")
norbix hub notifications email template update --viewId tmpl_77HajPbb0ijj4ij0uQTMNF --templateName "Order shipped" --communicationChannel Transactional --translations "$TR"
```

The first line reads the current translations; add or change one in `$TR` before the second line saves them.

API: [Update Email Template](/codemash/api-reference/notifications/email/update-email-template.md) · [Get Email Template](/codemash/api-reference/notifications/email/get-email-template.md)
