Click or drag to resize

MessageT1, T2, T3, T4, T5 Constructor

Constructs a localizable message.

Namespace:  KSPDev.GUIUtils
Assembly:  KSPDev_Utils.2.0 (in KSPDev_Utils.2.0.dll) Version: 2.0 for KSP v1.8+
Syntax
C#
public Message(
	string tag,
	string defaultTemplate = null,
	string description = null,
	string example = null
)
Request Example View Source

Parameters

tag
Type: SystemString
The tag to use when getting the localized version of the template. If null then the message will alaways use defaultTemplate as text.
defaultTemplate (Optional)
Type: SystemString

The template to use if no localizable content can be found. It can be in any language, but it's strongly encouraged to put it in English. For the template syntax see the documentation on the Lingoona website.

If this parameter is omitted, then the tag will be used as a default template. I.e. in case of the tag lookup failed, the tag string will be presented instead of a human readable string.

description (Optional)
Type: SystemString
A helper text for the translators to give them a context. Try to be reasonably verbose when specifying the circumstances of when this string is displayed. The context does matter!
example (Optional)
Type: SystemString
An example of how the template can be used and what is the output in the langauge of the defaultTemplate. Provide it to illustrate the non-obvious cases.
Examples
public class Message5Demo : PartModule {
  // The encouraged way of defining a message.
  static readonly Message<string, int, string, int, float> msg1 =
      new Message<string, int, string, int, float>(
          "#myLocalizationTag",
          defaultTemplate: "<<1>> = <<2>>, <<3>> = <<4>>, avg = <<5>>",
          description: "A string to present in the KSPDevUtils documentation example. It"
          + " illustrates how the class can be used to localize a message.",
          example: "v1 = 1, v2 = 2, avg = 1.5");

  // A simple way when no extra details are provided.
  static readonly Message<string, int, string, int, float> msg2 = "#myLocalizationTag";

  public override void OnAwake() {
    base.OnAwake();

    // This will load the localized string and print it into the log.
    HostedDebugLog.Info(this, msg1.Format("v1", 1, "v2", 2, 1.5f));

    // The next example will only work if there is a localizable string defined. Otherwise, it will
    // print the tag.
    HostedDebugLog.Info(this, msg2.Format("v1", 1, "v2", 2, 1.5f));
  }
}
See Also