From eddd005d34159ab7890c2795707157d4bef5d6c4 Mon Sep 17 00:00:00 2001 From: Daan Boerlage Date: Mon, 25 Jan 2021 01:40:51 +0100 Subject: [PATCH] Add translations for !corona --- src/Bot/Bot.csproj | 9 ++ src/Bot/Commands/Utils/Corona/CoronaStats.cs | 21 ++-- src/Bot/Localization/Corona.Designer.cs | 117 +++++++++++++++++++ src/Bot/Localization/Corona.de-ch.resx | 32 +++++ src/Bot/Localization/Corona.resx | 39 +++++++ 5 files changed, 207 insertions(+), 11 deletions(-) create mode 100644 src/Bot/Localization/Corona.Designer.cs create mode 100644 src/Bot/Localization/Corona.de-ch.resx create mode 100644 src/Bot/Localization/Corona.resx diff --git a/src/Bot/Bot.csproj b/src/Bot/Bot.csproj index ec32e8f..6c6f56f 100644 --- a/src/Bot/Bot.csproj +++ b/src/Bot/Bot.csproj @@ -84,6 +84,10 @@ ResXFileCodeGenerator Stats.Designer.cs + + ResXFileCodeGenerator + Corona.Designer.cs + @@ -144,5 +148,10 @@ True Stats.resx + + True + True + Corona.resx + diff --git a/src/Bot/Commands/Utils/Corona/CoronaStats.cs b/src/Bot/Commands/Utils/Corona/CoronaStats.cs index 15431d2..e39be0a 100644 --- a/src/Bot/Commands/Utils/Corona/CoronaStats.cs +++ b/src/Bot/Commands/Utils/Corona/CoronaStats.cs @@ -9,17 +9,16 @@ using Geekbot.Core; using Geekbot.Core.Converters; using Geekbot.Core.ErrorHandling; using Geekbot.Core.Extensions; +using Geekbot.Core.GuildSettingsManager; namespace Geekbot.Bot.Commands.Utils.Corona { - public class CoronaStats : ModuleBase + public class CoronaStats : GeekbotCommandBase { - private readonly IErrorHandler _errorHandler; private readonly IEmojiConverter _emojiConverter; - public CoronaStats(IErrorHandler errorHandler, IEmojiConverter emojiConverter) + public CoronaStats(IErrorHandler errorHandler, IGuildSettingsManager guildSettingsManager, IEmojiConverter emojiConverter) : base(errorHandler, guildSettingsManager) { - _errorHandler = errorHandler; _emojiConverter = emojiConverter; } @@ -50,7 +49,7 @@ namespace Geekbot.Bot.Commands.Utils.Corona var deathsFormatted = summary.Deaths.ToString(numberFormat); var embedTitleBuilder = new StringBuilder(); - embedTitleBuilder.Append("Confirmed Corona Cases"); + embedTitleBuilder.Append(Localization.Corona.ConfirmedCases); if (!string.IsNullOrEmpty(summary.Country)) { embedTitleBuilder.Append(" - "); @@ -66,20 +65,20 @@ namespace Geekbot.Bot.Commands.Utils.Corona }, Footer = new EmbedFooterBuilder { - Text = "Source: covid19-api.org", + Text = $"{Localization.Corona.Source}: covid19-api.org", }, Color = Color.Red }; - eb.AddField("Total", totalFormatted); - eb.AddInlineField("Active", $"{activeFormatted} ({activePercent})"); - eb.AddInlineField("Recovered", $"{recoveredFormatted} ({recoveredPercentage})"); - eb.AddInlineField("Deaths", $"{deathsFormatted} ({deathsPercentage})"); + eb.AddField(Localization.Corona.Total, totalFormatted); + eb.AddInlineField(Localization.Corona.Active, $"{activeFormatted} ({activePercent})"); + eb.AddInlineField(Localization.Corona.Recovered, $"{recoveredFormatted} ({recoveredPercentage})"); + eb.AddInlineField(Localization.Corona.Deaths, $"{deathsFormatted} ({deathsPercentage})"); await Context.Channel.SendMessageAsync(String.Empty, false, eb.Build()); } catch (Exception e) { - await _errorHandler.HandleCommandException(e, Context); + await ErrorHandler.HandleCommandException(e, Context); } } diff --git a/src/Bot/Localization/Corona.Designer.cs b/src/Bot/Localization/Corona.Designer.cs new file mode 100644 index 0000000..b243bfc --- /dev/null +++ b/src/Bot/Localization/Corona.Designer.cs @@ -0,0 +1,117 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Geekbot.Bot.Localization { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Corona { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Corona() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Geekbot.Bot.Localization.Corona", typeof(Corona).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Active. + /// + internal static string Active { + get { + return ResourceManager.GetString("Active", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Confirmed Corona Cases. + /// + internal static string ConfirmedCases { + get { + return ResourceManager.GetString("ConfirmedCases", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Deaths. + /// + internal static string Deaths { + get { + return ResourceManager.GetString("Deaths", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Recovered. + /// + internal static string Recovered { + get { + return ResourceManager.GetString("Recovered", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Source. + /// + internal static string Source { + get { + return ResourceManager.GetString("Source", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Total. + /// + internal static string Total { + get { + return ResourceManager.GetString("Total", resourceCulture); + } + } + } +} diff --git a/src/Bot/Localization/Corona.de-ch.resx b/src/Bot/Localization/Corona.de-ch.resx new file mode 100644 index 0000000..3c4180c --- /dev/null +++ b/src/Bot/Localization/Corona.de-ch.resx @@ -0,0 +1,32 @@ + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Bstätigti Corona Fallzahle + + + Total + + + Aktiv + + + Erholt + + + Gstorbe + + + Quelle + + \ No newline at end of file diff --git a/src/Bot/Localization/Corona.resx b/src/Bot/Localization/Corona.resx new file mode 100644 index 0000000..44bf85e --- /dev/null +++ b/src/Bot/Localization/Corona.resx @@ -0,0 +1,39 @@ + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Confirmed Corona Cases + + + Total + + + Active + + + Recovered + + + Deaths + + + Source + + \ No newline at end of file