Click or drag to resize

IsLocalizableModule Interface

Generic interface for the modules that manage own localizable items.

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

The IsLocalizableModule type exposes the following members.

Methods
  NameDescription
Public methodCode exampleLocalizeModule
A callback which is called when the localization vesion has changed.
Top
Remarks
The "item" can be anything. If the module pays special attention to deal with the "items", then it should implement this interface so that the notification could be sent when the language has changed (or updated). Here are some examples of the localizable items:
  • KSP events, actions or fields that are attributed with LocalizableItemAttribute. The module would want to call the LoadItemsInModule(PartModule) method to have the strings updated.
  • Cached strings. The module would want to refresh the cache.
  • Dynamically created part menu items. The module would want to recreate them. If that's the case it's always better to implement IHasContextMenu, and then just call the update method.
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