From 79dabe26717654364d50c927678f52caed1ab93c Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 24 May 2017 13:48:17 -0400 Subject: add translation API (#296) --- src/StardewModdingAPI/ITranslationHelper.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/StardewModdingAPI/ITranslationHelper.cs (limited to 'src/StardewModdingAPI/ITranslationHelper.cs') diff --git a/src/StardewModdingAPI/ITranslationHelper.cs b/src/StardewModdingAPI/ITranslationHelper.cs new file mode 100644 index 00000000..84571d0e --- /dev/null +++ b/src/StardewModdingAPI/ITranslationHelper.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using StardewValley; + +namespace StardewModdingAPI +{ + /// Provides translations stored in the mod's i18n folder, with one file per locale (like en.json) containing a flat key => value structure. Translations are fetched with locale fallback, so missing translations are filled in from broader locales (like pt-BR.json < pt.json < default.json). + public interface ITranslationHelper + { + /********* + ** Accessors + *********/ + /// The current locale. + string Locale { get; } + + /// The game's current language code. + LocalizedContentManager.LanguageCode LocaleEnum { get; } + + + /********* + ** Public methods + *********/ + /// Get all translations for the current locale. + IDictionary GetTranslations(); + + /// Get a translation for the current locale. + /// The translation key. + Translation Translate(string key); + } +} -- cgit