---
title: "Multilingual Pages"
description: "Multilingual Pages keep several language versions (mutations) of one landing page in a single template and let users switch between them in the editor."
url: https://docs.topol.io/landing-page-editor/guide/multilingual-pages.html
---

# Multilingual Pages

**Multilingual Pages store several language versions (mutations) of one landing page in a single JSON template.** The blocks hold the **Primary** language; every other language keeps only its translated texts, so no separate template per language is needed.

To get the HTML of a specific language, render the template with that language code: either through `editor.save({ langCode })` or through the conversion API with `options.language`. The list of languages is delivered as a `mutations` array next to `json` and `html` in the `onSave` callback.

## How to Enable

Add the option to your configuration object:

```ts
multilingual: true,
```

Defining the languages a new page starts with through `defaultTemplateSettings.langs` turns the feature on by itself, so `multilingual` can be left out in that case:

```ts
defaultTemplateSettings: {
  langs: [
    { code: "en", primary: true },
    { code: "cs" },
  ],
},
```

Once enabled, the editor's Top Bar shows a language dropdown. It is the hub for the languages of the page: create, switch and delete languages, or change which one is Primary. Hide it with `hideTopbarControls: ["changeLanguage"]`.

Language codes are BCP 47 tags (`cs`, `en-GB`, `pt-BR`). They are case-insensitive everywhere (`EN` and `en` are the same language, in the dropdown, in `editor.save({ langCode })` and in `options.language`) and are stored and reported back exactly as they were given. A code that is not a language tag (`en US`, `e`) is refused.

## Workflow

The user can design the page first and add a language later, or add a language first and then design. The first language added becomes Primary and simply labels the current content.

Adding another language and selecting it shows the same page: nothing is translated yet, so the editor falls back to the Primary texts. While that language is selected, every text the user rewrites is stored for that language only; the Primary page stays untouched. Switching back shows the Primary texts again. This works for:

-   text and raw HTML blocks, button labels and links,
-   image, GIF and video `src`, `alt`, `title` and image links,
-   navbar menu items, the CTA button, the logo and the hamburger label,
-   social network links and `alt` texts,
-   form field labels and placeholders, the submit button text and the success message,
-   the page `title`, `description`, `keywords` and the social-sharing (og) image in the settings. The page Language (`<html lang>`) is not edited by hand on a multilingual page: every render carries the code of its language (the Primary's on save), so the Settings field is hidden.

Styling, layout and structure are shared by all languages. Adding, removing or reordering blocks and form fields changes the page for every language.

One language is always Primary. It cannot be deleted, but another language can be made Primary at any time: the texts of the new Primary move into the blocks and the previous Primary becomes an ordinary language with its own translations. Making the original language Primary again restores the previous state: the other language keeps only what it had actually translated or edited meanwhile. Deleting a language the user is looking at switches the editor back to the Primary one.

> **AI-Powered Translation**
>
> With [AI features](https://docs.topol.io/landing-page-editor/guide/ai-features.html) enabled, every language in the dropdown has a translate button that fills it from the Primary language (or from any other language through the arrow next to it), and **Translate all** translates every language at once. Links and image URLs are never translated. One translation runs at a time; while it runs, languages cannot be created, deleted or made Primary.

## Saving Multilingual Pages

`onSave` and `onSaveAndClose` receive one payload object with `json`, `html` and `mutations`:

```ts
const editor = LandingPageEditor({
  config: OPTIONS,
  onSave({ json, html, mutations }) {
    // mutations: [{ code: "en", primary: true }, { code: "cs", primary: false }]
  },
});
```

`mutations` is present only for a page with languages; a page without them delivers `json` and `html` as before.

#### html

-   **Save button in the editor**: `html` is **always the Primary language**.
-   **Your own save button**: call `editor.save({ langCode: "cs" })` to receive the HTML of that language. Without `langCode` you get the Primary language. The argument is an object: `editor.save("cs")` is treated as a call without a language. A `langCode` the page does not have (a typo, or a language the user deleted meanwhile) rejects the Promise with `UnknownLanguageError` and fires no `onSave`; the primary language is never returned in its place. Across the embed boundary the error arrives as a plain `Error` whose `message` starts with `Language "…" is not defined`.

> **WARNING**
>
> Do not call `editor.save({ langCode })` inside `onSave` for every language of the `mutations` array: each call fires another `onSave` and creates an infinite loop. Render the other languages with the conversion API instead.

#### json

`json` is the whole page: the blocks in the Primary language plus a `langs` array with every language and its translations.

```json
{
  "tagName": "mj-global-style",
  "metadata": { "title": "Spring sale", "lang": "en", "...": "..." },
  "children": ["..."],
  "langs": [
    { "key": "en", "primary": true, "translations": {} },
    {
      "key": "cs",
      "primary": false,
      "metadata": { "title": "Jarní výprodej" },
      "translations": {
        "text-uid": { "content": "<p>Ahoj</p>" },
        "button-uid": { "content": "Koupit", "attributes": { "href": "/cs/koupit" } },
        "form-uid": {
          "submitButtonText": "Odeslat",
          "fields": { "field-uuid": { "label": "Jméno" } }
        }
      }
    }
  ]
}
```

Translations are keyed by the block `uid`; an empty or missing value means the Primary text is used. In the editor a cleared field stays empty while the user is typing into it and shows the Primary text again once they leave it. Store the JSON as a whole and load it back with `editor.load(json)`.

## Rendering a Specific Language

Both rendering endpoints accept `options.language`:

```json
{
  "definition": "<the saved json, stringified>",
  "options": { "fonts": "[]", "language": "cs" }
}
```

The response is the HTML of that language with `<html lang="cs">` and the translated metadata. A page without languages has exactly one, its page language (`metadata.lang`): `options.language` with that code renders it, any other code is rejected like an unknown one. A right-to-left language (Arabic, Hebrew, Persian, Urdu and the other RTL scripts, recognised by the base of the code, so `ar-EG` counts) is rendered with `<html lang="ar" dir="rtl">`, and the editor canvas shows it right-to-left while it is selected; a direction set on a single text block through the text toolbar still wins inside that block. Without `language` the Primary language is rendered. A code the template does not define is rejected (`400` from `/landing-page/get-html`, `422` from `/landing-page/v1/json2html`).

See [Rendering outside the editor](https://docs.topol.io/landing-page-editor/guide/template-export.html#rendering-outside-the-editor) for the endpoints.

## Managing Languages from the Host

The editor instance exposes the language actions, so a host application can drive them from its own UI:

```ts
editor.createLanguage("de"); // createLanguage(code, primary = false) → boolean
editor.selectLanguage("de"); // → boolean
editor.setPrimaryLanguage("de"); // → boolean
editor.deleteLanguage("cs"); // → boolean
editor.getMutations(); // also answered through onGetMutations({ mutations })
editor.translateLanguage("de"); // AI, from the primary (second argument: source code) → Promise<boolean>
editor.translateAllLanguages(); // → Promise<boolean>
```

Each method answers `false` when it did nothing: an invalid or duplicate code, the Primary language passed to `deleteLanguage`, a language change requested while an AI translation runs, or a translation requested while AI is off (`disableAiAssistant`, or no AI on the account) or another translation is still running. The translate methods resolve `true` only when every text was translated. With Multilingual Pages off (no `multilingual: true` and no `defaultTemplateSettings.langs`) all of them do nothing: a language the host created would be saved with the page without the user ever seeing a language dropdown.

Every change is reported through callbacks, including one made by undo or redo (a restored language arrives as `onLanguageCreated`, a removed one as `onLanguageDeleted`, a moved Primary flag as `onPrimaryLanguageChanged`):

| Callback | Payload |
| --- | --- |
| `onLanguageCreated` | `{ code, mutations }` |
| `onLanguageDeleted` | `{ code, mutations }` |
| `onPrimaryLanguageChanged` | `{ code, mutations }` |
| `onLanguageSelected` | `{ code }` – the language shown in the editor (`null` for a page without languages) |
| `onGetMutations` | `{ mutations }` – answer to `getMutations()` |

## Custom Language Preset

The add-language picker offers the ISO 639 language list. Replace it, or extend it with `override: false`:

```ts
customLanguagePreset: {
  langs: [
    { name: "Czech", code: "cs", nativeName: "Čeština" },
    { name: "Slovak", code: "sk", nativeName: "Slovenčina" },
  ],
  override: true,
},
```

The `code` is more than a label: it is written as `<html lang>` of that language's HTML and is the `langCode` you pass to `editor.save()` and the `language` you pass to the conversion API. Use a language tag browsers understand (`cs`, `en-GB`, `pt-BR`), not an internal id. An invalid preset (an entry without `name`, `code` or `nativeName`) is rejected together with the rest of the options at start-up, like any other invalid option.

## Limitations

-   Translations of saved and synced sections live with the section in your saved-sections API (the `translation` field, see [API Integration for Saved Sections](https://docs.topol.io/landing-page-editor/guide/content-blocks.html#api-integration-for-saved-sections)). When a section is inserted into a page that has no languages, or whose Primary language the section lacks, the editor asks which stored language to show; a synced section remembers the choice as `syncedLang` on its instance in the page JSON, and its edits are saved back into that language only (the editor confirms this on save and shows the language as a badge on the section). A translation made on a synced section outside its edit mode is a local change of the page and is replaced on the next refresh, like any other edit of the section body.
-   The page is still delivered as one HTML per render. Serving every language at its own URL, or switching languages inside one page, is the host's job.
