summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Translation.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-05-24 17:00:23 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-05-24 17:00:23 -0400
commitf5063cf81e68d142a5af6209ef80fd29fd80fce2 (patch)
tree6674a42d5df3baa178441a4e19d4f07c86386ad2 /src/StardewModdingAPI/Translation.cs
parent79dabe26717654364d50c927678f52caed1ab93c (diff)
downloadSMAPI-f5063cf81e68d142a5af6209ef80fd29fd80fce2.tar.gz
SMAPI-f5063cf81e68d142a5af6209ef80fd29fd80fce2.tar.bz2
SMAPI-f5063cf81e68d142a5af6209ef80fd29fd80fce2.zip
add translation unit tests (#296)
Diffstat (limited to 'src/StardewModdingAPI/Translation.cs')
-rw-r--r--src/StardewModdingAPI/Translation.cs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/StardewModdingAPI/Translation.cs b/src/StardewModdingAPI/Translation.cs
index ae4b833c..868ee4fa 100644
--- a/src/StardewModdingAPI/Translation.cs
+++ b/src/StardewModdingAPI/Translation.cs
@@ -11,6 +11,9 @@ namespace StardewModdingAPI
/*********
** Properties
*********/
+ /// <summary>The placeholder text when the translation is <c>null</c> or empty, where <c>{0}</c> is the translation key.</summary>
+ internal const string PlaceholderText = "(no translation:{0})";
+
/// <summary>The name of the relevant mod for error messages.</summary>
private readonly string ModName;
@@ -36,7 +39,7 @@ namespace StardewModdingAPI
/// <param name="key">The translation key.</param>
/// <param name="text">The underlying translation text.</param>
internal Translation(string modName, string locale, string key, string text)
- : this(modName, locale, key, text, $"(no translation:{key})") { }
+ : this(modName, locale, key, text, string.Format(Translation.PlaceholderText, key)) { }
/// <summary>Construct an isntance.</summary>
/// <param name="modName">The name of the relevant mod for error messages.</param>
@@ -75,7 +78,7 @@ namespace StardewModdingAPI
/// <param name="use">Whether to return a placeholder.</param>
public Translation UsePlaceholder(bool use)
{
- return new Translation(this.ModName, this.Locale, this.Key, this.Text, use ? $"(no translation:{this.Key})" : null);
+ return new Translation(this.ModName, this.Locale, this.Key, this.Text, use ? string.Format(Translation.PlaceholderText, this.Key) : null);
}
/// <summary>Replace tokens in the text like <c>{{value}}</c> with the given values. Returns a new instance.</summary>