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

Represents a sprite localized by language, either through direct assignment or via a global key. More...

Classes

class  LocalizedSpriteValue
 Structure representing a sprite for a specific language. More...
 

Public Member Functions

 if (!string.IsNullOrEmpty(key))
 
 if (match !=null &&match.sprite !=null) return match.sprite
 
 foreach (var s in sprites)
 

Static Public Member Functions

static implicit operator Sprite (LocalizedSprite localizedSprite)
 Implicit conversion from LocalizedSprite to Sprite. Allows using LocalizedSprite where a Sprite is expected.
 

Public Attributes

string key
 Key used to retrieve a localized sprite from the LocalizationManager. If empty or not found, the system falls back to local sprites list.
 
List< LocalizedSpriteValuesprites = new List<LocalizedSpriteValue>()
 List of localized sprite entries for each language. Used when no key is provided or key lookup fails.
 
class Backbone::LocalizedSprite::LocalizedSpriteValue language = LocalizationManager.instance?.currentLanguage
 Returns the sprite corresponding to the current language. Priority: Lookup by key in manager -> fallback to local list -> fallback to first sprite or null.
 
var match = sprites.Find(s => s.language == language)
 
return null
 

Detailed Description

Represents a sprite localized by language, either through direct assignment or via a global key.

This class allows for two localization strategies:

  1. Define a key that maps to a centralized sprite in the LocalizationManager.
  2. Define localized sprites directly in the sprites list for each language.

The system will first try to resolve the key through the LocalizationManager. If no match is found or the key is empty, it will fallback to the internal list of localized sprites.

Example usage:

  1. LocalizedSprite with direct values: LocalizedSprite mySprite = new LocalizedSprite(); mySprite.sprites.Add(new LocalizedSprite.LocalizedSpriteValue { language = "English", sprite = myEnglishSprite }); Sprite s = mySprite.Sprite;
  2. LocalizedSprite using key: LocalizedSprite mySprite = new LocalizedSprite(); mySprite.key = "ui.button.play"; Sprite s = mySprite.Sprite;

Member Function Documentation

◆ foreach()

Backbone::LocalizedSprite::foreach ( var s in sprites)

◆ if() [1/2]

Backbone::LocalizedSprite::if ( !string. IsNullOrEmptykey)

◆ if() [2/2]

Backbone::LocalizedSprite::if ( match ! = null &&match.sprite !=null)

◆ operator Sprite()

static implicit Backbone::LocalizedSprite::operator Sprite ( LocalizedSprite localizedSprite)
static

Implicit conversion from LocalizedSprite to Sprite. Allows using LocalizedSprite where a Sprite is expected.

Member Data Documentation

◆ key

string Backbone::LocalizedSprite::key

Key used to retrieve a localized sprite from the LocalizationManager. If empty or not found, the system falls back to local sprites list.

◆ language

class Backbone::LocalizedSprite::LocalizedSpriteValue Backbone::LocalizedSprite::language = LocalizationManager.instance?.currentLanguage

Returns the sprite corresponding to the current language. Priority: Lookup by key in manager -> fallback to local list -> fallback to first sprite or null.

◆ match

var Backbone::LocalizedSprite::match = sprites.Find(s => s.language == language)

◆ null

return Backbone::LocalizedSprite::null

◆ sprites

List<LocalizedSpriteValue> Backbone::LocalizedSprite::sprites = new List<LocalizedSpriteValue>()

List of localized sprite entries for each language. Used when no key is provided or key lookup fails.


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