Skip to content

Plugin Structure

Galahane Rouillé-Poirel edited this page Jun 19, 2023 · 3 revisions

The scripts are under the namespace "SinGala.Plugins.Localization", as well as "SinGala.Plugins.Localization.SaveSystem" for the example save system.

Language.cs

Enum of the different supported languages

LocalizationManager.cs

  • public static Language Language {get; private set;} : The current language
  • public static event Action OnLanguageChanged : The event that is called when the current language is updated. All the Localizers are subscribing to it
  • public static void LanguageChanged() : Calls the OnLanguageChanged event
  • public static T GetLocalizedValue(Translations translationDatas) : Returns the correct Localized Value from the given Translations Datas depending on the current language
  • public static TranslationDatas GetLocalizedDatas(Translations translationDatas) : Returns the full translations datas corresponding to the current language
  • public static Language SetBaseLanguage() : Set the current language to the Application.systemLanguage of the device or to the default you set if the language isn't supported
  • public static void SetLanguage(Language newLanguage) : Set the current language to the specified one

Localizer.cs

  • [SerializeField] protected Translations _translationsDatas : The Translations Scriptable Object - used by the Localizer to know what are the possible localization values
  • public abstract void UpdateValue() : Update the value of the needed component (Image, Sprite, TextMeshProUGUI, etc.) with the correct localized data
  • public void SetNewTranslationsDatas(Translations translations) : Update the possible translations datas values of this specific localizer

TextLocalizer.cs

Used with strings and TextMeshProUGUI

ImageLocalizer.cs

Used with Sprites and Image

SpriteLocalizer.cs

Used with Sprites and SpriteRenderer

TextDropdownLocalizer

Used with strings and TMP_Dropdown

SpriteDropdownLocalizer

Used with Sprites and TMP_Dropdown

Translations.cs

Scriptable Object

  • [field: SerializeField] public virtual TranslationDatas[] Datas { get; protected set; } : The translations datas of a specific content (text, image)

TextTranslations

Used for strings

SpriteTranslations

Used for Sprites

Special Translations for Dropdowns

  • [field: SerializeField] public virtual List<Translations> Datas { get; protected set; }

TextDropdownTranslations

Used for Dropdowns that uses strings

SpriteDropdownTranslations

Used for Dropdowns that uses Sprites

TranslationDatas.cs

  • [field: SerializeField] public Language Language { get; private set; } : The language that the datas are linked to
  • [field: SerializeField] public T LocalizedDatas { get; private set; } : The strings or Sprites needed for this specific language
  • [field: SerializeField] public bool IsRTL { get; private set; } : Used on strings to switch between RTL and LTR languages