Click or drag to resize

LocalizableItemAttribute Class

Attribute for the various game items that support localization.
Inheritance Hierarchy
SystemObject
  SystemAttribute
    KSPDev.GUIUtilsLocalizableItemAttribute

Namespace:  KSPDev.GUIUtils
Assembly:  KSPDev_Utils.2.0 (in KSPDev_Utils.2.0.dll) Version: 2.0 for KSP v1.8+
Syntax
C#
[AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Field, AllowMultiple = true)]
public class LocalizableItemAttribute : Attribute
Request Example View Source

The LocalizableItemAttribute type exposes the following members.

Constructors
  NameDescription
Public methodLocalizableItemAttribute
Initializes a new instance of the LocalizableItemAttribute class
Top
Methods
  NameDescription
Public methodGetLocalizedString
Returns the localized string.
Top
Fields
  NameDescription
Public fieldCode exampledefaultTemplate
Template to use if no localized template found.
Public fieldCode exampledescription
Description for the message.
Public fieldCode examplespec
A key to distinguish attributes when there are multiple of them attached to a member.
Public fieldCode exampletag
Tag to use when resolving the string via the Localizer.
Top
Remarks

Use this attribute to automatically localize the part's events, fields, and actions. The relevant strings will be loaded when the vessel or part is either created or loaded. The strings will also properly update when reloading the language definitiaion via LocalizationTool.

See the "seealso" section for the types and methods that are aware of this attribute.

Examples
[KSPField(guiName = "just-in-case text", guiActive = true)]
[LocalizableItem(
    tag = "#tag1",
    defaultTemplate = "English text 1",
    description = "A field which demonstrates a localizable GUI string")]
public string field1 = "";

// This field doesn't have guiName and it would, normally, be treated as a non-GUI field. However,
// due to the localization attribute, the guiName value will be assigned when the module is
// loaded.
[KSPField(guiActive = true)]
[LocalizableItem(
    tag = "#tag2",
    defaultTemplate = "English text 2",
    description = "A field which demonstrates a localizable GUI string without guiName")]
public string field2 = "";
Examples
[KSPEvent(guiName = "just-in-case text", guiActive = true)]
[LocalizableItem(
    tag = "#tag1",
    defaultTemplate = "English text",
    description = "A field which demonstrates a localizable event")]
public void MyEvent1() {
  Debug.Log("MyEvent1 invoked");
}
Examples
[KSPEvent(guiName = "just-in-case text", guiActive = true)]
[LocalizableItem(
    tag = "#tag1",
    defaultTemplate = "English text",
    description = "A field which demonstrates a localizable action")]
public void MyAction1() {
  Debug.Log("MyAction1 invoked");
}
See Also