summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-06-04 16:22:15 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-06-04 16:22:15 -0400
commit36930ffd7d363d6afd7f8cac4918c7d1c1c3e339 (patch)
tree44c3bcc8bedf718c24ae92dd5c9094a398d5e630 /src/StardewModdingAPI/Framework
parentf8718e044bae89a96431c19e3f3dc11637bad426 (diff)
parentfd485abe28632eda50765f1113ab9f3f453589aa (diff)
downloadSMAPI-36930ffd7d363d6afd7f8cac4918c7d1c1c3e339.tar.gz
SMAPI-36930ffd7d363d6afd7f8cac4918c7d1c1c3e339.tar.bz2
SMAPI-36930ffd7d363d6afd7f8cac4918c7d1c1c3e339.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI/Framework')
-rw-r--r--src/StardewModdingAPI/Framework/TranslationHelper.cs15
1 files changed, 8 insertions, 7 deletions
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));
}
}
}