Click or drag to resize

MessageT1, T2, T3Format Method

Formats the message template string with the provided arguments.

Namespace:  KSPDev.GUIUtils
Assembly:  KSPDev_Utils.2.0 (in KSPDev_Utils.2.0.dll) Version: 2.0 for KSP v1.8+
Syntax
C#
public string Format(
	T1 arg1,
	T2 arg2,
	T3 arg3
)
Request Example View Source

Parameters

arg1
Type: T1
The substitute for the <<1>> argument.
arg2
Type: T2
The substitute for the <<2>> argument.
arg3
Type: T3
The substitute for the <<3>> argument.

Return Value

Type: String
A complete and localized message string.
Remarks
The string parameter(s) can be template tags. If the type of the argument is string, and the value matches a tag, then the localized string of this tag is used instead. Keep it in mind when defining the tags to avoid the collisions.
Examples
public class Message3Demo : PartModule {
  // The encouraged way of defining a message.
  static readonly Message<string, int, float> msg1 = new Message<string, int, float>(
      "#myLocalizationTag",
      defaultTemplate: "The value of <<1>> is <<2>> or <<3>>",
      description: "A string to present in the KSPDevUtils documentation example. It illustrates"
      + " how the class can be used to localize a message.",
      example: "The value of Blah is 123 or 123.5");

  // A simple way when no extra details are provided.
  static readonly Message<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("Blah", 123, 123.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("Blah", 123, 123.5f));
  }
}
See Also