Heroic Engine
  • Welcome
  • Getting Started
    • Quickstart
    • Example Games
      • Tic Tac Toe
      • Turn based duel
  • Basics
    • Injection Manager
    • Engine Systems
      • Core Systems
        • Events Manager
        • Input Manager
        • Localization Manager
          • LangText component
        • Music Player
        • Sounds Manager
        • Time Manager
        • Scenes Loader
        • Day Time Controller
        • Weather Controller
      • Gameplay Systems
        • Currencies Manager
        • Player Progression Manager
        • Quest Manager
        • Random Events Manager
        • Hittables Manager
        • Dungeon Generator
      • UI Systems
        • UI Controller
        • Countdown Controller
    • Editor Tools
      • Clear Saves
      • Mobile Build Optimizer
      • Create System
      • Icon from Prefab Generator
    • Engine Utilities
      • PoolSystem
      • DataSaver
      • ComponentExtensions
      • MaterialExtensions
      • SpriteUtils
      • SlowUpdate
      • StringUtils
      • TypeUtility
      • MathHelper
      • VectorUtils
      • TransformUtils
      • MeshUtils
    • Useful Components
      • Floating Item
      • Fly Up Text
      • Label Scaler
      • Ragdoll
      • Rotate To Camera
      • Orbital Camera
      • Rotator
      • Texture Mover
      • Hittable
      • Projectile
      • Projectile2D
      • LifetimeObject
      • Spawner
      • Colorized Particles
      • Draggable2D
      • SaveableTransform
    • Useful Attributes
Powered by GitBook
On this page
  1. Basics
  2. Engine Systems
  3. Core Systems

Localization Manager

Presented via ILocalizationManager interface, this system processes localization in your project.

Currently Localization Manager supports only localization files in *.txt format with key=value pairs inside. But in future we're planning to extend this system functionality, so it will support more localization data formats.

To use this system, inject ILocalizationManager interface into your class, as shown below:

[Inject] private ILocalizationManager localizationManager;

Available methods

void SwitchLanguage(SystemLanguage lang)

This method switches current language to the needed one, passed via lang parameter.

Example:

localizationManager.SwitchLanguage(SystemLanguage.French);

string GetLocalizedString(string id)

This method returns localized string with id localization key. If this key is not presented in localization table, it just returns id.

Example:

resultLabel.text = localizationManager.GetLocalizedString("Success");

string GetLocalizedString<T>(string id, params T[] args)

This method returns localized string with id localization key and custom parameters args. If this key is not presented in localization table, it just returns id. Parameters can have any types, convertable to string. In localization table parameters are presented as {0}, {1}, ... {N} terms.

Example:

Localization key and value
Attempt=Attempt {0}
Getting localized string
attemptLabel.text = localizationManager.GetLocalizedString("Attempt", attemptNumber);

So, in case if attemptNumber = 3, this method returns:

Attempt 3

string GetLocalizedString<T>(string id, Color paramsColor, params T[] args)

This method returns localized string with id localization key and custom parameters args. If this key is not presented in localization table, it just returns id. Parameters can have any types, convertable to string. In localization table parameters are presented as {0}, {1}, ... {N} terms. Parameters in localized string will be shown with text color equal to paramsColor.

Example:

attemptLabel.text = localizationManager.GetLocalizedString("Attempt", Color.green, attemptNumber);

void ResolveTexts()

List<SystemLanguage> GetAvailableLanguages()

This method returns list of available languages in project (languages which have their translation files in Assets/Resources/Localization folder).


SystemLanguage GetCurrentLanguage()

This method returns current language in game.

PreviousInput ManagerNextLangText component

Last updated 4 months ago

This method finds and translates all Text, TMP_Text and TextMesh components in project. It processes them only in case if that GameObjects also have component with assigned localization key. This method is automatically called right after calling SwitchLanguage method.

LangText