DocsBehavior

Localization

A text layer opts into translation with a key. Its content is the text in the base language; tables hold the other languages.

"i18n": {
  "base": "en",
  "tables": {
    "de": { "title.press": "Beliebige Taste drücken" },
    "fr": { "title.press": "Appuyez sur une touche" }
  }
}
"text": { "content": "Press any button", "key": "title.press" }
  • Translations can use data templates like {player.name} and list templates like {item.name}.
  • A missing translation shows the base text.
  • Locales match exactly first, then by language: de-AT finds de, pt finds pt-BR.
  • pseudo shows accented text about 35% longer than the base, so you find clipping before real translations arrive.

In the editor

On the Localization page edit a German translation, pick German in the Languages list, and see the canvas show it.

Localization (G L) holds every key in every language side by side.

  • Languages lists the base language and the others. Type a code in Add language: de, fr, pt-BR… to add one. Click a language to show it on the canvas, and Pseudo for the pseudo-locale.
  • Keys for N texts gives a key to every text layer that has none.
  • Export writes a CSV for translators: the key, the source text and one column per language. Import CSV reads it back. Cells in the file replace the ones in Envy.
  • Text overflow lists text that no longer fits its layer, measured from the real layout. Missing translations lists empty cells.
  • A text layer’s key and its translations are also in the inspector’s Text section. Typing on the canvas while a language is shown edits that translation.

Preview has a Language list too, with the pseudo-locale.

Styled text

A text with styled parts keeps them in a translation through tags. Each tag is a number and names the run it styles, counting from 0:

"text": {
  "content": "Deal {damage} damage",
  "key": "card.damage",
  "runs": [ { "text": "Deal " }, { "text": "{damage}", "weight": 700 }, { "text": " damage" } ]
}
"de": { "card.damage": "Mach <1>{damage}</1> Schaden" }

On the Localization page, the base language shows the same tags, and the CSV export writes them, so translators see which words carry the style. They can move a tag or repeat it. Words outside any tag take the text’s own style. A string with no tags is plain.

Tags can’t nest, each one must name a run and be closed, and nothing inside {…} counts as a tag. A tag that doesn’t match shows the translation as plain text, never as visible tags, and the row gets a Tags warning. The check is i18n-tags in the document checks. A text with no styled parts never reads tags. The pseudo-locale keeps the styling.

Controls and tooltips

A tooltip is translated with its Key field in the Tooltip section. A select’s option labels and a control’s placeholder take keys too: key on each option, and placeholderKey on the control.

"control": { "kind": "select", "path": "settings.quality", "placeholderKey": "quality.pick",
             "options": [ { "value": "low", "label": "Low", "key": "quality.low" }, { "value": "high", "label": "High", "key": "quality.high" } ] }

These keys count like layer keys in the Localization page, the CSV and the checks. The editor’s Control section has no field for the option and placeholder keys, so add them to the document, or have an agent set them with patch_node.

Text that shrinks to fit is checked in every language: it counts as fitting unless it reaches its minimum size and still overflows. Expressions use the language in use for the number formatter.

At runtime

ui.locale = TranslationServer.get_locale()
ui.set_locale("de")
const ui = Envy.mount(host, doc, { locale: navigator.language });
ui.setLocale("fr");

Switching keeps data, overlays and focus. Godot rebuilds the open screens in place, so animations started by game code stop and autoplay animations start again. The web runtime only changes the text.

01 Title in The Last Hunt · UI kit v2 is translated into German, French, Spanish and Brazilian Portuguese. Switch language in the live demo.

Text that shows a component property ({prop.Label}) isn’t translated by key: translate the value the instance sets instead.

Updated View as Markdown