Click or drag to resize

LocalizationLoader Class

A utility class to localize the annotated members
Inheritance Hierarchy
SystemObject
  UnityEngineObject
    UnityEngineComponent
      UnityEngineBehaviour
        UnityEngineMonoBehaviour
          KSPDev.GUIUtilsLocalizationLoader

Namespace:  KSPDev.GUIUtils
Assembly:  KSPDev_Utils.2.3 (in KSPDev_Utils.2.3.dll) Version: 2.3 for KSP v1
Syntax
C#
public class LocalizationLoader : MonoBehaviour
Request Example View Source

The LocalizationLoader type exposes the following members.

Constructors
  NameDescription
Public methodLocalizationLoader
Initializes a new instance of the LocalizationLoader class
Top
Methods
  NameDescription
Public methodStatic memberCode exampleLoadItemsInModule
Localizes the PartModule items.
Top
Remarks

It also monitors if the localization version has changed. If this is the case, then all the localizable modules will be notified.

This module is initialized from the KSPDev Utils loader.

Examples
public class LocalizationLoaderDemo1 : PartModule {
  public class OtherModule : PartModule {
    [KSPField(guiName = "just-in-case text", guiActive = true)]
    [LocalizableItem(tag = "#tag1")]
    public string field1 = "";
  }

  public void AddCustomModule() {
    var newModule = gameObject.AddComponent<OtherModule>();
    LocalizationLoader.LoadItemsInModule(newModule);
  }
}
Examples
public class LocalizationLoaderDemo2 : PartModule, IsLocalizableModule {
  [KSPField(guiActive = true)]
  [LocalizableItem(tag = "#tag1", defaultTemplate = "Field1")]
  [LocalizableItem(tag = "#tag2", defaultTemplate = "units",
                   spec = StdSpecTags.Units)]
  public string field1 = "";

-  #region IsLocalizableModule implementation
   public void LocalizeModule() {
     LocalizationLoader.LoadItemsInModule(this);
   }
   #endregion

  public override void OnAwake() {
    base.OnAwake();
    LocalizeModule();
  }
}
See Also