Localization

Turian uses one localization system for your game and for Studio itself. Translations live in string table assets; code and UI documents look text up by key, and the active locale can change while the game runs.

String tables

Each locale is one .strings file anywhere under Assets/ — for example Assets/Localization/pt-BR.strings:

{
  "locale": "pt-BR",
  "entries": [
    { "key": "menu.play", "source": "Play", "translation": "Jogar", "state": "translated" },
    { "key": "menu.quit", "source": "Quit", "translation": "Sair", "state": "translated",
      "note": "Main menu, last button" },
    { "key": "inventory.items", "source": "{count} items",
      "plurals": { "one": "# item", "other": "# itens" }, "state": "translated" }
  ]
}

source is the original text, translation the localized one, and state tracks progress (new, translated, …) for translators. Every table in the project is loaded when the game starts.

Project settings

The Localization Settings asset (New → Settings → Localization Settings in the Assets panel) declares the Default Locale the game starts in and the Available Locales it offers.

Looking up text in code

var title = Localization.T("menu.play");                        // "Jogar" in pt-BR
var fallback = Localization.T("menu.credits", fallback: "Credits");
var items = Localization.T("inventory.items", count: 3);         // "3 itens"
var source = Localization.Source("Game over");                   // the text itself is the key

Localization.SetLocale("pt-BR");
Log.Logger.LogInformation("Now in {Locale}", Localization.ActiveLocale);

Lookups never throw: a missing key returns the fallback (or the key), and when no tables are loaded every call returns its input. Resolution falls back from a region to its language — pt-BR → pt — and then to the default locale.

To refresh text you cache, subscribe to Localization.Service?.LocaleChanged.

Looking up text in UI documents

Label text in a .ui document is localized automatically: the authored text is used as its own key. Give an element a text-key to look up an explicit key instead:

<Label text="Play" />                          <!-- looked up by its source text -->
<Button text="Quit" text-key="menu.quit" />    <!-- looked up by key -->

See Game UI.

Messages, plurals and choices

Messages support a compact subset of ICU MessageFormat:

Form Example
Substitution Hello, {name}!
Plural block {count, plural, one {# apple} other {# apples}}
Select block {gender, select, female {She} male {He} other {They}} won
Per-entry plural forms the plurals object of an entry, keyed zero, one, two, few, many, other

# stands for the count. Plural categories follow each language's CLDR rules, so Portuguese, Polish or Arabic pick the right form.

Working with translators

Studio's editor library converts tables to and from the formats translation tools use — XLIFF 1.2 and CSV — keeping key, source, target, note and state. That lets a translator work in their own tool while the project keeps .strings as its source of truth.

Trying a locale

Play Mode and the CLI can force a locale for one session:

turian-cli playmode MyGame --locale pt-BR --out pt-br.png
turian-cli screenshot MyGame --locale ja --out ja.png

Studio itself

Studio is localized with the same system. Switch its language under Edit → Localization; English and Brazilian Portuguese ship with 1.0.


← All docs Edit this page