---
title: "Templates in several languages - Workflow Documents"
description: "Add languages to a document template, translate its HTML and file name, set the main language, and see how the language of a document is chosen."
canonical: "https://docs.workflow-documents.app/languages"
---

# Templates in several languages

One template can hold the same document in several languages. The template itself is its **main language**. Every added language has its own HTML and its own file name, and shares everything else with the template. When a document is generated, the language is picked for you, usually from the customer.

## The main language

The main language is the language the template is written in. A customer without a matching language gets this version.

You find it as **Main language** on the **Settings** tab of the editor. The selector suggests your store's language. The first time you add a language, the app asks you to confirm the main language of the template.

## Add a language

1. Open the template and save any open changes.
2. Select **Add language** at the top.
3. If nobody chose it yet, select the **Main language of this template**.
4. Select the **Language to add** and confirm.

The new language starts as a copy of the template. There is no automatic translation: open the language and translate it yourself. A template can have up to 30 added languages.

## Translate a language

Once a template has an added language, a language selector appears next to the tabs. Pick a language to open its editor. It looks like the template editor with two tabs:

- **HTML** - the content in this language. Translate the texts, keep the Liquid.
- **Settings** - the **File name** in this language.

The preview on the right shows the document in this language, with amounts formatted for it.

CSS, branding, paper size and all other settings are shared by all languages. Change them in the main language.

A language is saved like a template: **Save** in the bar at the top, and a save is refused when the HTML does not render.

> [!WARNING]
> **Changes to the main language are not copied**
> A language is a copy from the moment you added it. When you later add a column or a paragraph to the main language, make the same change in each added language.

## How the language of a document is chosen

In this order:

1. **The Language field of the action.** When the **Language** field of the Generate document action (or `language` in the API) holds a language code, that language is used.
2. **The customer's language.** Without it, the language of the order's customer is used for an order template, and the customer's own language for a customer template. A product has no language of its own.
3. **The main language.** When there is no language, or the template does not have it, the main language is rendered.

A matching language does not have to match exactly:

| Asked for | Template has | Rendered |
| --- | --- | --- |
| de | de | German |
| de-CH | de | German. A regional request is served by the base language |
| pt | pt-br | Portuguese (Brazil). A base request is served by a regional version |
| fr | no French | The main language |

## Set the Language field in Flow

To be explicit, set the **Language** field of the Generate document action to the order's customer locale:

```liquid
{{order.customerLocale}}
```

Or enter a fixed code such as *de* when a document should always be in one language, for example a packing slip for your warehouse. See [Set up the Generate document action in Shopify Flow](https://docs.workflow-documents.app/set-up-the-generate-document-action-in-shopify-flow.md).

## The language variable

Inside a template, `language` holds the language the document is made for: the one that was asked for or detected, else the main language. Money is formatted for it. You can branch on it, which is handy for a few words in a template that has no added languages:

```liquid
{% if language == "de" %}Vielen Dank{% else %}Thank you{% endif %}
```

`language` is what was asked for, not which version was rendered. A request for *de-at* prints *de-at*, also when the German version served it.

## Set as main language

Open an added language and select **Set as main language**. That language becomes the template itself, and the former main language becomes an added language. Nothing is lost: the two trade places. From then on, a document without a language, or in a language the template does not have, is generated in the new main language.

## Delete a language

Open the language and select **Delete** with the language's name. Customers with that language get the main language from the next document on. This cannot be undone.

## Good to know

- Languages are added and edited in the app. The Developer API lists a template's languages and generates a document in one, but cannot write them.
- The language selector offers the most common languages. The Language field of the action accepts any language code.

## Next steps

- [Paper size, margins and file name](https://docs.workflow-documents.app/paper-size-and-file-name.md) - the file name per language.
- [Example workflows](https://docs.workflow-documents.app/example-workflows.md) - a workflow that sends each customer their language.
