Backbone - Localization
 
Loading...
Searching...
No Matches
Backbone::LocalizedText Class Reference

Automatically updates a legacy UnityEngine.UI.Text component with a localized string. More...

Inheritance diagram for Backbone::LocalizedText:

Public Attributes

LocalizedString localizedString
 Localized string data (can use a key or inline values).
 

Private Member Functions

void Awake ()
 
void OnEnable ()
 
void OnDisable ()
 
void UpdateText ()
 Updates the Text component with the appropriate localized value.
 

Private Attributes

Text textComponent
 

Detailed Description

Automatically updates a legacy UnityEngine.UI.Text component with a localized string.

This component uses a LocalizedString object, which supports two modes:

  1. Key-based: The string is retrieved from the central LocalizationManager using a defined key.
  2. Inline: If no key match is found, the component uses the local language-specific values in the LocalizedString.

The component subscribes to language change events and updates the text accordingly.

Usage:

  1. Attach this component to a GameObject with a Text component (from UnityEngine.UI).
  2. In the Inspector, either:
    • Set a key inside the localizedString, and define the text centrally via CSV or asset.
    • Or assign the localized values manually inside the LocalizedString.

Example 1 – using a key: localizedString.key = "ui.greeting"

Example 2 – using inline values: localizedString.values = { ["English"] = "Hello", ["Spanish"] = "Hola" }

Notes:

  • Requires a Text component.
  • Displays a warning message if no match is found.

Member Function Documentation

◆ Awake()

void Backbone::LocalizedText::Awake ( )
private

◆ OnDisable()

void Backbone::LocalizedText::OnDisable ( )
private

◆ OnEnable()

void Backbone::LocalizedText::OnEnable ( )
private

◆ UpdateText()

void Backbone::LocalizedText::UpdateText ( )
private

Updates the Text component with the appropriate localized value.

Member Data Documentation

◆ localizedString

LocalizedString Backbone::LocalizedText::localizedString

Localized string data (can use a key or inline values).

◆ textComponent

Text Backbone::LocalizedText::textComponent
private

The documentation for this class was generated from the following file: