Message Constructor |
Namespace: KSPDev.GUIUtils
public Message( string tag, string defaultTemplate = null, string description = null, string example = null )
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.
public class MessageDemo : PartModule { // The encouraged way of defining a message. static readonly Message msg1 = new Message( "#myLocalizationTag", defaultTemplate: "Sample text in English", description: "A string to present in the KSPDevUtils documentation example. It illustrates" + " how the class can be used to localize a message.", example: "Sample text in English"); // A simple way when no extra details are provided. static readonly Message 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()); // The next example will only work if there is a localizable string defined. Otherwise, it will // print the tag. HostedDebugLog.Info(this, msg2.Format()); // A simple message can be just casted to string to get the localized content. PrintString(msg1); } void PrintString(string str) { HostedDebugLog.Info(this, str); } }