LocalizationLoaderLoadItemsInModule Method |
Namespace: KSPDev.GUIUtils
public static void LoadItemsInModule( PartModule module )
The localizable items must be declared as non-static public members. The following items are supported:
The original KSP attributes don't need to specify guiName field since it will be overwritten anyway. However, it's a good idea to give a default value just in case.
This method can be called at any time during the module's life. However, the LocalizeModule method looks the most appropriate.
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); } }
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(); } }