In case response key is missing, use the string from ResponseStrings.resx

This commit is contained in:
Kwoth 2017-02-13 17:16:31 +01:00
parent 66f046a77c
commit de4b1fdbf5

View File

@ -57,9 +57,20 @@ namespace NadekoBot.Modules
// return Context.Channel.SendErrorAsync(title, text, url, footer);
//}
/// <summary>
/// Used as failsafe in case response key doesn't exist in the selected or default language.
/// </summary>
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)