Skip to main content

I18nService API

The I18nService class is responsible for managing internationalization (i18n) in the application. It handles language settings, loading translations, and replacing translation placeholders.

MethodParametersReturnsDescription
SetLanguageLanguageChanges the current display language.
GetLanguageLanguageGets the current display language.
GetLanguageAssetLanguageLanguageAssetGiven a language identifier it returns the corresponding language asset from loaded translation files.
GetI18nTextSubscriptionsHandlerI18nTextSubscriptionsHandlerGets the current I18nTextSubscriptionsHandler instance.
AssetsHaveBeenLoadedboolReturns wether i18n translation files have been loaded or not.
SceneAssetsHaveBeenLoadedboolReturns wether i18n scene translations have been loaded.
SceneManagerHasBeenLoadedboolReturns wether the i18n scene manager has been loaded in the scene.
LoadTranslationsTranslationSets[]Given an array of TranslationSets it replaces in-memory translations with the provided array.
Translate
  • string: path.
  • TranslationSets: translation Dictionary<string string> (replacements)
string

Given a translation path and a translation set it searches in the translation set for the translation corresponding to the path. If a translation is found, it tries to replace defined variables with those passed as a Dictionary (dictionary key is variable, and value is the variable value). It returns a string representing the translated and replaced value.

ReplaceTranslationPlaceholders
  • string: translation entry.
  • Dictionary<string, string>: replacements
stringGiven a translated string that can contain replacement variables, it returns it with variables replaced with the values from the dictionary.
GetGlobalReplacements

Dictionary<string, string>

It returns the global replacements dictionary.
SetGlobalReplacement
  • string: replacement key.
  • string: replacement value.
Given a replacement key and a value, it adds it to the global replacements.
RemoveGlobalReplacement
  • string: replacement key.
Given a replacement key, it removes it.
ClearGlobalReplacementsRemoves all global replacements.
AppendGlobalReplacementsAppends a dictionary to the current global replacements.