summaryrefslogtreecommitdiff
path: root/src/SMAPI/ITranslationHelper.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-10-14 11:44:02 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-10-14 11:44:02 -0400
commit79118316065a01322d8ea12a14589ec016794c32 (patch)
tree7a26668a66ea0630a2b9367ac820fe7a6d99ac77 /src/SMAPI/ITranslationHelper.cs
parentaf1a2bde8219c5d4b8660b13702725626a4a5647 (diff)
parent8aec1eff99858716afe7b8604b512181f78c214f (diff)
downloadSMAPI-79118316065a01322d8ea12a14589ec016794c32.tar.gz
SMAPI-79118316065a01322d8ea12a14589ec016794c32.tar.bz2
SMAPI-79118316065a01322d8ea12a14589ec016794c32.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/ITranslationHelper.cs')
-rw-r--r--src/SMAPI/ITranslationHelper.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/SMAPI/ITranslationHelper.cs b/src/SMAPI/ITranslationHelper.cs
new file mode 100644
index 00000000..c4b72444
--- /dev/null
+++ b/src/SMAPI/ITranslationHelper.cs
@@ -0,0 +1,34 @@
+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 : IModLinked
+ {
+ /*********
+ ** 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>
+ IEnumerable<Translation> GetTranslations();
+
+ /// <summary>Get a translation for the current locale.</summary>
+ /// <param name="key">The translation key.</param>
+ Translation Get(string key);
+
+ /// <summary>Get a translation for the current locale.</summary>
+ /// <param name="key">The translation key.</param>
+ /// <param name="tokens">An object containing token key/value pairs. This can be an anonymous object (like <c>new { value = 42, name = "Cranberries" }</c>), a dictionary, or a class instance.</param>
+ Translation Get(string key, object tokens);
+ }
+}