From ee154fdb33717a7fd9b22f26c73a8039dbc6c0b2 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Mon, 30 Oct 2023 23:29:47 -0500 Subject: [PATCH] Add translation helper methods to API --- NewHorizons/INewHorizons.cs | 31 +++++++++++++++++++++++++++++++ NewHorizons/NewHorizonsApi.cs | 8 ++++++++ 2 files changed, 39 insertions(+) diff --git a/NewHorizons/INewHorizons.cs b/NewHorizons/INewHorizons.cs index 903b76e5..096960d3 100644 --- a/NewHorizons/INewHorizons.cs +++ b/NewHorizons/INewHorizons.cs @@ -173,5 +173,36 @@ namespace NewHorizons /// A dictionary of each curiousity ID to its colour and highlight colour in the ship log. Optional. void AddShipLogXML(IModBehaviour mod, XElement xml, string planetName, string imageFolder = null, Dictionary entryPositions = null, Dictionary curiousityColours = null); #endregion + + #region Translations + /// + /// Look up shiplog-related translated text for the given text key. + /// Defaults to English if no translation in the current language is available, and just the key if no English translation is available. + /// + /// The text key to look up. + /// + string GetTranslationForShipLog(string text); + /// + /// Look up dialogue-related translated text for the given text key. + /// Defaults to English if no translation in the current language is available, and just the key if no English translation is available. + /// + /// The text key to look up. + /// + string GetTranslationForDialogue(string text); + /// + /// Look up UI-related translated text for the given text key. + /// Defaults to English if no translation in the current language is available, and just the key if no English translation is available. + /// + /// The text key to look up. + /// + string GetTranslationForUI(string text); + /// + /// Look up miscellaneous translated text for the given text key. + /// Defaults to English if no translation in the current language is available, and just the key if no English translation is available. + /// + /// The text key to look up. + /// + string GetTranslationForOtherText(string text); + #endregion } } diff --git a/NewHorizons/NewHorizonsApi.cs b/NewHorizons/NewHorizonsApi.cs index 0b25a339..f269cce9 100644 --- a/NewHorizons/NewHorizonsApi.cs +++ b/NewHorizons/NewHorizonsApi.cs @@ -322,5 +322,13 @@ namespace NewHorizons /// /// public void RegisterCustomBuilder(Action builder) => PlanetCreationHandler.CustomBuilders.Add(builder); + + public string GetTranslationForShipLog(string text) => TranslationHandler.GetTranslation(text, TranslationHandler.TextType.SHIPLOG); + + public string GetTranslationForDialogue(string text) => TranslationHandler.GetTranslation(text, TranslationHandler.TextType.DIALOGUE); + + public string GetTranslationForUI(string text) => TranslationHandler.GetTranslation(text, TranslationHandler.TextType.UI); + + public string GetTranslationForOtherText(string text) => TranslationHandler.GetTranslation(text, TranslationHandler.TextType.OTHER); } }