From ac43d087b175686081b8e29d1e0f86e008b09e8c Mon Sep 17 00:00:00 2001 From: runebaas Date: Sun, 21 Jul 2019 13:00:02 +0200 Subject: [PATCH] Add the !cookie alias and allow yaml alliases in the translations file --- Geekbot.net/Commands/Rpg/Cookies.cs | 1 + Geekbot.net/Lib/Localization/TranslationHandler.cs | 6 +++--- Geekbot.net/Lib/Localization/Translations.yml | 5 ++++- Tests/Lib/Localization/Translations.test.cs | 4 +++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Geekbot.net/Commands/Rpg/Cookies.cs b/Geekbot.net/Commands/Rpg/Cookies.cs index 3c41044..b1a2d7d 100644 --- a/Geekbot.net/Commands/Rpg/Cookies.cs +++ b/Geekbot.net/Commands/Rpg/Cookies.cs @@ -15,6 +15,7 @@ namespace Geekbot.net.Commands.Rpg { [DisableInDirectMessage] [Group("cookies")] + [Alias("cookie")] public class Cookies : ModuleBase { private readonly DatabaseContext _database; diff --git a/Geekbot.net/Lib/Localization/TranslationHandler.cs b/Geekbot.net/Lib/Localization/TranslationHandler.cs index 3d1ee3a..a7a1a12 100644 --- a/Geekbot.net/Lib/Localization/TranslationHandler.cs +++ b/Geekbot.net/Lib/Localization/TranslationHandler.cs @@ -8,8 +8,7 @@ using Geekbot.net.Database; using Geekbot.net.Database.Models; using Geekbot.net.Lib.Extensions; using Geekbot.net.Lib.Logger; -using Utf8Json; -using YamlDotNet.RepresentationModel; +using YamlDotNet.Core; using YamlDotNet.Serialization; namespace Geekbot.net.Lib.Localization @@ -39,8 +38,9 @@ namespace Geekbot.net.Lib.Localization // Deserialize var input = new StringReader(translationFile); + var mergingParser = new MergingParser(new Parser(input)); var deserializer = new DeserializerBuilder().Build(); - var rawTranslations = deserializer.Deserialize>>>(input); + var rawTranslations = deserializer.Deserialize>>>(mergingParser); // Sort var sortedPerLanguage = new Dictionary>>(); diff --git a/Geekbot.net/Lib/Localization/Translations.yml b/Geekbot.net/Lib/Localization/Translations.yml index 4bf4d14..730ea40 100644 --- a/Geekbot.net/Lib/Localization/Translations.yml +++ b/Geekbot.net/Lib/Localization/Translations.yml @@ -85,7 +85,7 @@ roll: NoPrevGuess: EN: ":red_circle: {0}, you can't guess the same number again" CHDE: ":red_circle: {0}, du chasch nid nomol es gliche rate" -cookies: +cookies: &cookiesAlias GetCookies: EN: "You got {0} cookies, there are now {1} cookies in you cookie jar" CHDE: "Du häsch {0} guetzli becho, du häsch jetzt {1} guetzli ih dr büchse" @@ -107,6 +107,9 @@ cookies: AteCookies: EN: "You ate {0} cookies, you've only got {1} cookies left" CHDE: "Du hesch {0} guetzli gesse und hesch jezt no {1} übrig" +cookie: + # because command aliases are to hard to deal with... + <<: *cookiesAlias role: NoRolesConfigured: EN: "There are no roles configured for this server" diff --git a/Tests/Lib/Localization/Translations.test.cs b/Tests/Lib/Localization/Translations.test.cs index fc43091..736ed83 100644 --- a/Tests/Lib/Localization/Translations.test.cs +++ b/Tests/Lib/Localization/Translations.test.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using FluentAssertions; using Xunit; +using YamlDotNet.Core; using YamlDotNet.Serialization; namespace Tests.Lib.Localization @@ -17,8 +18,9 @@ namespace Tests.Lib.Localization // Deserialize var input = new StringReader(translationFile); + var mergingParser = new MergingParser(new Parser(input)); var deserializer = new DeserializerBuilder().Build(); - var rawTranslations = deserializer.Deserialize>>>(input); + var rawTranslations = deserializer.Deserialize>>>(mergingParser); // These languages must be supported var supportedLanguages = new List