diff --git a/Geekbot.net/Commands/Admin/Role.cs b/Geekbot.net/Commands/Admin/Role.cs index 47d7246..f0aa7bd 100644 --- a/Geekbot.net/Commands/Admin/Role.cs +++ b/Geekbot.net/Commands/Admin/Role.cs @@ -22,9 +22,9 @@ namespace Geekbot.net.Commands.Admin private readonly DatabaseContext _database; private readonly IErrorHandler _errorHandler; private readonly IReactionListener _reactionListener; - private readonly TranslationHandler _translationHandler; + private readonly ITranslationHandler _translationHandler; - public Role(DatabaseContext database, IErrorHandler errorHandler, IReactionListener reactionListener, TranslationHandler translationHandler) + public Role(DatabaseContext database, IErrorHandler errorHandler, IReactionListener reactionListener, ITranslationHandler translationHandler) { _database = database; _errorHandler = errorHandler; diff --git a/Geekbot.net/Commands/Utils/Quote/Quote.cs b/Geekbot.net/Commands/Utils/Quote/Quote.cs index a6f3ec9..84a3786 100644 --- a/Geekbot.net/Commands/Utils/Quote/Quote.cs +++ b/Geekbot.net/Commands/Utils/Quote/Quote.cs @@ -8,6 +8,7 @@ using Geekbot.net.Database.Models; using Geekbot.net.Lib.CommandPreconditions; using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.Extensions; +using Geekbot.net.Lib.Localization; using Geekbot.net.Lib.Polyfills; using Geekbot.net.Lib.RandomNumberGenerator; @@ -20,12 +21,14 @@ namespace Geekbot.net.Commands.Utils.Quote private readonly IErrorHandler _errorHandler; private readonly DatabaseContext _database; private readonly IRandomNumberGenerator _randomNumberGenerator; + private readonly ITranslationHandler _translationHandler; - public Quote(IErrorHandler errorHandler, DatabaseContext database, IRandomNumberGenerator randomNumberGenerator) + public Quote(IErrorHandler errorHandler, DatabaseContext database, IRandomNumberGenerator randomNumberGenerator, ITranslationHandler translationHandler) { _errorHandler = errorHandler; _database = database; _randomNumberGenerator = randomNumberGenerator; + _translationHandler = translationHandler; } [Command] @@ -38,7 +41,8 @@ namespace Geekbot.net.Commands.Utils.Quote if (!s.Any()) { - await ReplyAsync("This server doesn't seem to have any quotes yet. You can add a quote with `!quote save @user` or `!quote save `"); + var transContext = await _translationHandler.GetGuildContext(Context); + await ReplyAsync(transContext.GetString("NoQuotesFound")); return; } @@ -60,15 +64,16 @@ namespace Geekbot.net.Commands.Utils.Quote { try { + var transContext = await _translationHandler.GetGuildContext(Context); if (user.Id == Context.Message.Author.Id) { - await ReplyAsync("You can't save your own quotes..."); + await ReplyAsync(transContext.GetString("CannotSaveOwnQuotes")); return; } if (user.IsBot) { - await ReplyAsync("You can't save quotes by a bot..."); + await ReplyAsync(transContext.GetString("CannotQuoteBots")); return; } @@ -80,7 +85,7 @@ namespace Geekbot.net.Commands.Utils.Quote await _database.SaveChangesAsync(); var embed = QuoteBuilder(quote); - await ReplyAsync("**Quote Added**", false, embed.Build()); + await ReplyAsync(transContext.GetString("QuoteAdded"), false, embed.Build()); } catch (Exception e) { @@ -95,16 +100,17 @@ namespace Geekbot.net.Commands.Utils.Quote { try { + var transContext = await _translationHandler.GetGuildContext(Context); var message = await Context.Channel.GetMessageAsync(messageId); if (message.Author.Id == Context.Message.Author.Id) { - await ReplyAsync("You can't save your own quotes..."); + await ReplyAsync(transContext.GetString("CannotSaveOwnQuotes")); return; } if (message.Author.IsBot) { - await ReplyAsync("You can't save quotes by a bot..."); + await ReplyAsync(transContext.GetString("CannotQuoteBots")); return; } @@ -113,7 +119,7 @@ namespace Geekbot.net.Commands.Utils.Quote await _database.SaveChangesAsync(); var embed = QuoteBuilder(quote); - await ReplyAsync("**Quote Added**", false, embed.Build()); + await ReplyAsync(transContext.GetString("QuoteAdded"), false, embed.Build()); } catch (Exception e) { @@ -168,17 +174,18 @@ namespace Geekbot.net.Commands.Utils.Quote { try { + var transContext = await _translationHandler.GetGuildContext(Context); var quote = _database.Quotes.Where(e => e.GuildId == Context.Guild.Id.AsLong() && e.InternalId == id)?.FirstOrDefault(); if (quote != null) { _database.Quotes.Remove(quote); await _database.SaveChangesAsync(); var embed = QuoteBuilder(quote); - await ReplyAsync($"**Removed #{id}**", false, embed.Build()); + await ReplyAsync(transContext.GetString("Removed", id), false, embed.Build()); } else { - await ReplyAsync("I couldn't find a quote with that id :disappointed:"); + await ReplyAsync(transContext.GetString("NotFoundWithId")); } } catch (Exception e) diff --git a/Geekbot.net/Lib/Localization/Translations.json b/Geekbot.net/Lib/Localization/Translations.json index 6a864fc..689085e 100644 --- a/Geekbot.net/Lib/Localization/Translations.json +++ b/Geekbot.net/Lib/Localization/Translations.json @@ -190,5 +190,31 @@ "EN": ["Removed {0} from the whitelist"], "CHDE": ["{0} isch vo dr whitelist glöscht"] } + }, + "quote": { + "NoQuotesFound": { + "EN": ["This server doesn't seem to have any quotes yet. You can add a quote with `!quote save @user` or `!quote save `"], + "CHDE": ["Dä server het no kei quotes. Du chasch quotes hinzuefüege mit `!quote save @user` oder `!quote save `"] + }, + "CannotSaveOwnQuotes": { + "EN": ["You can't save your own quotes..."], + "CHDE": ["Du chasch kei quotes vo dir selber speichere..."] + }, + "CannotQuoteBots": { + "EN": ["You can't save quotes by a bot..."], + "CHDE": ["Du chasch kei quotes vomne bot speichere..."] + }, + "QuoteAdded": { + "EN": ["**Quote Added**"], + "CHDE": ["**Quote hinzugfüegt**"] + }, + "Removed": { + "EN": ["**Removed #{0}**"], + "CHDE": ["**#{0} glöscht**"] + }, + "NotFoundWithId": { + "EN": ["I couldn't find a quote with that ID :disappointed:"], + "CHDE": ["Ich chan kei quote finde mit därri ID :disappointed:"] + } } } \ No newline at end of file