From f5063cf81e68d142a5af6209ef80fd29fd80fce2 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 24 May 2017 17:00:23 -0400 Subject: add translation unit tests (#296) --- src/StardewModdingAPI/Translation.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/StardewModdingAPI/Translation.cs') 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 *********/ + /// The placeholder text when the translation is null or empty, where {0} is the translation key. + internal const string PlaceholderText = "(no translation:{0})"; + /// The name of the relevant mod for error messages. private readonly string ModName; @@ -36,7 +39,7 @@ namespace StardewModdingAPI /// The translation key. /// The underlying translation text. 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)) { } /// Construct an isntance. /// The name of the relevant mod for error messages. @@ -75,7 +78,7 @@ namespace StardewModdingAPI /// Whether to return a placeholder. 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); } /// Replace tokens in the text like {{value}} with the given values. Returns a new instance. -- cgit