Meta

Localization

Resolves keys (notification codes etc.) to localized, interpolated strings with locale fallback; strings are game data via ILocalizationCatalog. Client-only, Core-only.

Unity package
com.crossplay.localization
Depends on
core
Shape
client-only · no server half

Unity seams you implement 1

The client half's sockets. Bind your implementation in the client context and Crossplay's client calls it — this is where your models, animators, UI and controls plug in.

ILocalizationCatalog unity SPI

The game's locale tables. An id/key means nothing to the framework, and strings are game data, so the game binds one or more catalogs that supply the templates per locale. Called when a locale is first activated. Fill the provided dictionary — do not clear it (multiple catalogs can contribute).

  • IReadOnlyList<string> Locales

    The locales this catalog can provide (e.g. "en", "fr", "ja").

  • void CollectEntries(string locale, IDictionary<string, string> into)

    Adds this catalog's key→template entries for locale to into.

Unity services you inject 1

Crossplay binds these in the client context. Inject and call them from your own MonoBehaviours and presenters.

ILocalization

App-wide localization: resolve keys to localized strings for the active locale, switch locales, and be told when it changes. Bound by the localization service; a game injects it wherever it renders user-facing text (or holds its own Localizer). Absent if the piece isn't installed.

  • string CurrentLocale

    The active locale.

  • string DefaultLocale

    The fallback locale used when the active one lacks a key.

  • event Action<string> LocaleChanged

    Raised after the locale changes, with the new locale.

  • void SetLocale(string locale)

    Switches locale, loading its entries from the catalogs on first use. No-op if unchanged.

  • string Localize(string key, params object[] args)

    The localized, interpolated string for a key (the key itself if missing).

  • bool Has(string key)

    Whether the key resolves in the active or default locale.