Understand how localization initializes, selects a locale, and resolves a value.
The LocalizationSettings asset holds the available locales, the startup locale selectors, the content sources, and the ResourceDatabase that resolves values. The asset ships with the Player and registers itself at startup.
Localization initializes once, the first time something asks for a localized value, or when you call InitializeAsync yourself. Initialization runs three steps in order:
ILocaleDiscovery can add locales it finds in its content. For example, a data-file source adds a locale for each table file it finds, so a build can gain a language after release. Refer to Add a language to a built Player.When initialization completes, localization raises InitializationCompleted, and any selector that needs one-time setup runs at this point.
flowchart TD
ref["LocalizedString / LocalizedAsset<br>(table reference + entry reference)"]
ref --> db["ResourceDatabase"]
db --> src["Content source chain<br>resolves the table for the selected locale"]
src --> entry["Entry lookup by key or ID"]
entry --> fb{"Value found?"}
fb -- no --> fallback["Retry with the locale's fallback"]
fallback --> entry
fb -- yes --> smart{"Smart string enabled?"}
smart -- yes --> fmt["Format with Smart Strings<br>(arguments + local variables)"]
smart -- no --> post
fmt --> post["Locale post-processing<br>(IPostProcessValueLocale)"]
post --> value["Value"]
classDef code fill:#F5F5F5,stroke:#BDBDBD,color:#111;
class ref,db,src,entry,fallback,fmt,post,value code;
linkStyle default stroke:#2196F3,stroke-width:1.5px;
A reference such as LocalizedString names a table collection and an entry. It resolves a value in the following order:
ResourceDatabase asks the content source chain for the collection’s table in the selected locale. Refer to Content sources.IPostProcessValueLocale, it post-processes the value. A pseudo-locale can use this hook to transform text for layout testing.Every step has a synchronous and an asynchronous path. Refer to Synchronous and asynchronous loading.
Localization raises LocalizationSettings.SelectedLocaleChanged when the language changes. References raise their own events too: a LocalizedString raises StringChanged with the new value, so UI subscribed to it updates without polling.