From de4b1fdbf5a211505c9b62e36891d50df6691504 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 13 Feb 2017 17:16:31 +0100 Subject: [PATCH] In case response key is missing, use the string from ResponseStrings.resx --- src/NadekoBot/Modules/NadekoModule.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/NadekoModule.cs b/src/NadekoBot/Modules/NadekoModule.cs index 24a21954..9311dac5 100644 --- a/src/NadekoBot/Modules/NadekoModule.cs +++ b/src/NadekoBot/Modules/NadekoModule.cs @@ -57,9 +57,20 @@ namespace NadekoBot.Modules // return Context.Channel.SendErrorAsync(title, text, url, footer); //} + /// + /// Used as failsafe in case response key doesn't exist in the selected or default language. + /// + private readonly CultureInfo usCultureInfo = new CultureInfo("en-US"); protected string GetText(string key) { - return NadekoBot.ResponsesResourceManager.GetString(LowerModuleTypeName + "_" + key, _cultureInfo); + var text = NadekoBot.ResponsesResourceManager.GetString(LowerModuleTypeName + "_" + key, _cultureInfo); + + if (string.IsNullOrWhiteSpace(text)) + { + _log.Warn(LowerModuleTypeName + "_" + key + " key is missing from " + _cultureInfo + " response strings. PLEASE REPORT THIS."); + return NadekoBot.ResponsesResourceManager.GetString(LowerModuleTypeName + "_" + key, usCultureInfo); + } + return text; } protected string GetText(string key, params object[] replacements)