summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/ITranslationHelper.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-05-24 13:48:17 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-05-24 13:48:17 -0400
commit79dabe26717654364d50c927678f52caed1ab93c (patch)
tree94d0b5aaa52e049b013fccc071437be09b9a826c /src/StardewModdingAPI/ITranslationHelper.cs
parent56919271fc60f85a752b0967fe27e69c1f3770c7 (diff)
downloadSMAPI-79dabe26717654364d50c927678f52caed1ab93c.tar.gz
SMAPI-79dabe26717654364d50c927678f52caed1ab93c.tar.bz2
SMAPI-79dabe26717654364d50c927678f52caed1ab93c.zip
add translation API (#296)
Diffstat (limited to 'src/StardewModdingAPI/ITranslationHelper.cs')
-rw-r--r--src/StardewModdingAPI/ITranslationHelper.cs29
1 files changed, 29 insertions, 0 deletions
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
+{
+ /// <summary>Provides translations stored in the mod's <c>i18n</c> folder, with one file per locale (like <c>en.json</c>) containing a flat key => value structure. Translations are fetched with locale fallback, so missing translations are filled in from broader locales (like <c>pt-BR.json</c> &lt; <c>pt.json</c> &lt; <c>default.json</c>).</summary>
+ public interface ITranslationHelper
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The current locale.</summary>
+ string Locale { get; }
+
+ /// <summary>The game's current language code.</summary>
+ LocalizedContentManager.LanguageCode LocaleEnum { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Get all translations for the current locale.</summary>
+ IDictionary<string, string> GetTranslations();
+
+ /// <summary>Get a translation for the current locale.</summary>
+ /// <param name="key">The translation key.</param>
+ Translation Translate(string key);
+ }
+}