Skip to main content
Folder: Packages/com.molca.core/Runtime/Localization/
Namespace: Molca.Localization
Core localization combines Unity Localization tables with Molca runtime helpers:
  • LocalizationModule (SettingModule) stores supported languages and active language code.
  • LocalizationManager (RuntimeSubsystem) bridges locale switching, text refresh, and dynamic runtime entries.
  • LocalizedText and DynamicLocalization are component/field helpers for UI text flows.

LocalizationModule (SettingModule)

File: LocalizationModule.cs
Create asset: Molca → Settings → Localization
  • Languages: array of language entries (name, Code, Flag sprite).
  • ActiveLanguage is persisted in module settings (SaveSettings / LoadSettings).
  • Runtime helpers: LanguageCode, ActiveLanguageEntry, GetFlagForLanguage(code).
Register this module on Global Settings.

LocalizationManager (RuntimeSubsystem)

File: LocalizationManager.cs Place on the RuntimeManager prefab. During initialize it waits for Unity Localization initialization, loads the active language from LocalizationModule, then applies it through LocalizationSettings.SelectedLocale.
  • Language switch API: LocalizationManager.SetLanguage(langCode)
  • Refresh path: locale change triggers TypedEvents.LanguageChanged.Dispatch(...) and refreshes registered localized texts.
  • Dynamic table key: Dynamic (used by UpdateEntry / GetLocale).
  • Also exposes helpers: GetLocalizedString(collectionName, entryKey) and GetLocalizedStringAsync(key).

LocalizedText (TMP component)

File: LocalizedText.cs
Requirement: TextMeshProUGUI
LocalizedText registers itself with LocalizationManager, subscribes to LocalizedString.StringChanged, then updates TMP text and rebuilds layout. Optional LocalizedTextStyleInfo assets (see Styles/) apply font/size presets.

DynamicLocalization (serializable field helper)

Files: DynamicLocalization.cs, DynamicLocalizationEntry.cs Use for runtime-managed strings (e.g. content loaded from API or generated labels):
  • Supports direct LocalizedString mode or per-language fallback list.
  • Init(key) syncs entries into the runtime Dynamic table through LocalizationManager.UpdateEntry(...).
  • GetLocalizedString() resolves current language with fallback to local entries/default language.

Code

Switch language from UI:
Bind a LocalizedString to a LocalizedText component:
  • Global Settings — register LocalizationModule
  • EventDispatcher — locale changes dispatch via TypedEvents.LanguageChanged
  • UI widgetsLanguageDropdown integrates with LocalizationManager.SetLanguage(...)

Unity Editor

Localization Inspector

Localization settings and runtime components