Applied codestyle to all .cs files

This commit is contained in:
Kwoth
2021-12-29 06:07:16 +01:00
parent 723447c7d4
commit 82000c97a4
543 changed files with 13221 additions and 14059 deletions

View File

@@ -7,9 +7,10 @@ namespace NadekoBot.Services;
public class BotStrings : IBotStrings
{
/// <summary>
/// Used as failsafe in case response key doesn't exist in the selected or default language.
/// Used as failsafe in case response key doesn't exist in the selected or default language.
/// </summary>
private readonly CultureInfo _usCultureInfo = new("en-US");
private readonly ILocalization _localization;
private readonly IBotStringsProvider _stringsProvider;
@@ -31,15 +32,16 @@ public class BotStrings : IBotStrings
if (string.IsNullOrWhiteSpace(text))
{
Log.Warning("'{Key}' key is missing from '{LanguageName}' response strings. You may ignore this message", key, cultureInfo.Name);
Log.Warning("'{Key}' key is missing from '{LanguageName}' response strings. You may ignore this message",
key,
cultureInfo.Name);
text = GetString(key, _usCultureInfo) ?? $"Error: dkey {key} not found!";
if (string.IsNullOrWhiteSpace(text))
{
return
$"I can't tell you if the command is executed, because there was an error printing out the response." +
$" Key '{key}' is missing from resources. You may ignore this message.";
}
"I can't tell you if the command is executed, because there was an error printing out the response."
+ $" Key '{key}' is missing from resources. You may ignore this message.";
}
return text;
}
@@ -51,39 +53,38 @@ public class BotStrings : IBotStrings
}
catch (FormatException)
{
Log.Warning(" Key '{Key}' is not properly formatted in '{LanguageName}' response strings. Please report this", key, cultureInfo.Name);
Log.Warning(
" Key '{Key}' is not properly formatted in '{LanguageName}' response strings. Please report this",
key,
cultureInfo.Name);
if (cultureInfo.Name != _usCultureInfo.Name)
return GetText(key, _usCultureInfo, data);
return
$"I can't tell you if the command is executed, because there was an error printing out the response.\n" +
$"Key '{key}' is not properly formatted. Please report this.";
"I can't tell you if the command is executed, because there was an error printing out the response.\n"
+ $"Key '{key}' is not properly formatted. Please report this.";
}
}
public CommandStrings GetCommandStrings(string commandName, ulong? guildId = null)
=> GetCommandStrings(commandName, _localization.GetCultureInfo(guildId));
public CommandStrings GetCommandStrings(string commandName, CultureInfo cultureInfo)
{
var cmdStrings = _stringsProvider.GetCommandStrings(cultureInfo.Name, commandName);
var cmdStrings = _stringsProvider.GetCommandStrings(cultureInfo.Name, commandName);
if (cmdStrings is null)
{
if (cultureInfo.Name == _usCultureInfo.Name)
{
Log.Warning("'{CommandName}' doesn't exist in 'en-US' command strings. Please report this",
commandName);
return new()
{
Args = new[] {""},
Desc = "?"
};
return new() { Args = new[] { "" }, Desc = "?" };
}
// Log.Warning(@"'{CommandName}' command strings don't exist in '{LanguageName}' culture.
// This message is safe to ignore, however you can ask in Nadeko support server how you can contribute command translations",
// commandName, cultureInfo.Name);
return GetCommandStrings(commandName, _usCultureInfo);
}
@@ -98,6 +99,7 @@ public class CommandStrings
{
[YamlMember(Alias = "desc")]
public string Desc { get; set; }
[YamlMember(Alias = "args")]
public string[] Args { get; set; }
}
}