summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI')
-rw-r--r--src/StardewModdingAPI/Constants.cs2
-rw-r--r--src/StardewModdingAPI/Framework/TranslationHelper.cs15
-rw-r--r--src/StardewModdingAPI/ITranslationHelper.cs2
-rw-r--r--src/StardewModdingAPI/Translation.cs10
4 files changed, 17 insertions, 12 deletions
diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs
index 4e53387e..bd489b29 100644
--- a/src/StardewModdingAPI/Constants.cs
+++ b/src/StardewModdingAPI/Constants.cs
@@ -33,7 +33,7 @@ namespace StardewModdingAPI
** Public
****/
/// <summary>SMAPI's current semantic version.</summary>
- public static ISemanticVersion ApiVersion { get; } = new SemanticVersion(1, 14, 0); // alpha-{DateTime.UtcNow:yyyyMMddHHmm}
+ public static ISemanticVersion ApiVersion { get; } = new SemanticVersion(1, 14, 1); // alpha-{DateTime.UtcNow:yyyyMMddHHmm}
/// <summary>The minimum supported version of Stardew Valley.</summary>
public static ISemanticVersion MinimumGameVersion { get; } = new SemanticVersion("1.2.30");
diff --git a/src/StardewModdingAPI/Framework/TranslationHelper.cs b/src/StardewModdingAPI/Framework/TranslationHelper.cs
index 1e73c425..fe387789 100644
--- a/src/StardewModdingAPI/Framework/TranslationHelper.cs
+++ b/src/StardewModdingAPI/Framework/TranslationHelper.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using StardewValley;
namespace StardewModdingAPI.Framework
@@ -17,7 +18,7 @@ namespace StardewModdingAPI.Framework
private readonly IDictionary<string, IDictionary<string, string>> All = new Dictionary<string, IDictionary<string, string>>(StringComparer.InvariantCultureIgnoreCase);
/// <summary>The translations for the current locale, with locale fallback taken into account.</summary>
- private IDictionary<string, string> ForLocale;
+ private IDictionary<string, Translation> ForLocale;
/*********
@@ -47,17 +48,17 @@ namespace StardewModdingAPI.Framework
}
/// <summary>Get all translations for the current locale.</summary>
- public IDictionary<string, string> GetTranslations()
+ public IEnumerable<Translation> GetTranslations()
{
- return new Dictionary<string, string>(this.ForLocale, StringComparer.InvariantCultureIgnoreCase);
+ return this.ForLocale.Values.ToArray();
}
/// <summary>Get a translation for the current locale.</summary>
/// <param name="key">The translation key.</param>
public Translation Get(string key)
{
- this.ForLocale.TryGetValue(key, out string text);
- return new Translation(this.ModName, this.Locale, key, text);
+ this.ForLocale.TryGetValue(key, out Translation translation);
+ return translation ?? new Translation(this.ModName, this.Locale, key, null);
}
/// <summary>Get a translation for the current locale.</summary>
@@ -91,7 +92,7 @@ namespace StardewModdingAPI.Framework
this.Locale = locale.ToLower().Trim();
this.LocaleEnum = localeEnum;
- this.ForLocale = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
+ this.ForLocale = new Dictionary<string, Translation>(StringComparer.InvariantCultureIgnoreCase);
foreach (string next in this.GetRelevantLocales(this.Locale))
{
// skip if locale not defined
@@ -102,7 +103,7 @@ namespace StardewModdingAPI.Framework
foreach (var pair in translations)
{
if (!this.ForLocale.ContainsKey(pair.Key))
- this.ForLocale.Add(pair);
+ this.ForLocale.Add(pair.Key, new Translation(this.ModName, this.Locale, pair.Key, pair.Value));
}
}
}
diff --git a/src/StardewModdingAPI/ITranslationHelper.cs b/src/StardewModdingAPI/ITranslationHelper.cs
index 15f6b3c8..dac83025 100644
--- a/src/StardewModdingAPI/ITranslationHelper.cs
+++ b/src/StardewModdingAPI/ITranslationHelper.cs
@@ -20,7 +20,7 @@ namespace StardewModdingAPI
** Public methods
*********/
/// <summary>Get all translations for the current locale.</summary>
- IDictionary<string, string> GetTranslations();
+ IEnumerable<Translation> GetTranslations();
/// <summary>Get a translation for the current locale.</summary>
/// <param name="key">The translation key.</param>
diff --git a/src/StardewModdingAPI/Translation.cs b/src/StardewModdingAPI/Translation.cs
index 764145ea..ce344f81 100644
--- a/src/StardewModdingAPI/Translation.cs
+++ b/src/StardewModdingAPI/Translation.cs
@@ -21,9 +21,6 @@ namespace StardewModdingAPI
/// <summary>The locale for which the translation was fetched.</summary>
private readonly string Locale;
- /// <summary>The translation key.</summary>
- private readonly string Key;
-
/// <summary>The underlying translation text.</summary>
private readonly string Text;
@@ -32,6 +29,13 @@ namespace StardewModdingAPI
/*********
+ ** Accessors
+ *********/
+ /// <summary>The original translation key.</summary>
+ public string Key { get; }
+
+
+ /*********
** Public methods
*********/
/// <summary>Construct an isntance.</summary>