Add the !cookie alias and allow yaml alliases in the translations file

This commit is contained in:
runebaas 2019-07-21 13:00:02 +02:00
parent 8fadff4092
commit ac43d087b1
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
4 changed files with 11 additions and 5 deletions

View file

@ -15,6 +15,7 @@ namespace Geekbot.net.Commands.Rpg
{ {
[DisableInDirectMessage] [DisableInDirectMessage]
[Group("cookies")] [Group("cookies")]
[Alias("cookie")]
public class Cookies : ModuleBase public class Cookies : ModuleBase
{ {
private readonly DatabaseContext _database; private readonly DatabaseContext _database;

View file

@ -8,8 +8,7 @@ using Geekbot.net.Database;
using Geekbot.net.Database.Models; using Geekbot.net.Database.Models;
using Geekbot.net.Lib.Extensions; using Geekbot.net.Lib.Extensions;
using Geekbot.net.Lib.Logger; using Geekbot.net.Lib.Logger;
using Utf8Json; using YamlDotNet.Core;
using YamlDotNet.RepresentationModel;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
namespace Geekbot.net.Lib.Localization namespace Geekbot.net.Lib.Localization
@ -39,8 +38,9 @@ namespace Geekbot.net.Lib.Localization
// Deserialize // Deserialize
var input = new StringReader(translationFile); var input = new StringReader(translationFile);
var mergingParser = new MergingParser(new Parser(input));
var deserializer = new DeserializerBuilder().Build(); var deserializer = new DeserializerBuilder().Build();
var rawTranslations = deserializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(input); var rawTranslations = deserializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(mergingParser);
// Sort // Sort
var sortedPerLanguage = new Dictionary<string, Dictionary<string, Dictionary<string, string>>>(); var sortedPerLanguage = new Dictionary<string, Dictionary<string, Dictionary<string, string>>>();

View file

@ -85,7 +85,7 @@ roll:
NoPrevGuess: NoPrevGuess:
EN: ":red_circle: {0}, you can't guess the same number again" EN: ":red_circle: {0}, you can't guess the same number again"
CHDE: ":red_circle: {0}, du chasch nid nomol es gliche rate" CHDE: ":red_circle: {0}, du chasch nid nomol es gliche rate"
cookies: cookies: &cookiesAlias
GetCookies: GetCookies:
EN: "You got {0} cookies, there are now {1} cookies in you cookie jar" 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" CHDE: "Du häsch {0} guetzli becho, du häsch jetzt {1} guetzli ih dr büchse"
@ -107,6 +107,9 @@ cookies:
AteCookies: AteCookies:
EN: "You ate {0} cookies, you've only got {1} cookies left" EN: "You ate {0} cookies, you've only got {1} cookies left"
CHDE: "Du hesch {0} guetzli gesse und hesch jezt no {1} übrig" CHDE: "Du hesch {0} guetzli gesse und hesch jezt no {1} übrig"
cookie:
# because command aliases are to hard to deal with...
<<: *cookiesAlias
role: role:
NoRolesConfigured: NoRolesConfigured:
EN: "There are no roles configured for this server" EN: "There are no roles configured for this server"

View file

@ -3,6 +3,7 @@ using System.IO;
using System.Linq; using System.Linq;
using FluentAssertions; using FluentAssertions;
using Xunit; using Xunit;
using YamlDotNet.Core;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
namespace Tests.Lib.Localization namespace Tests.Lib.Localization
@ -17,8 +18,9 @@ namespace Tests.Lib.Localization
// Deserialize // Deserialize
var input = new StringReader(translationFile); var input = new StringReader(translationFile);
var mergingParser = new MergingParser(new Parser(input));
var deserializer = new DeserializerBuilder().Build(); var deserializer = new DeserializerBuilder().Build();
var rawTranslations = deserializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(input); var rawTranslations = deserializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(mergingParser);
// These languages must be supported // These languages must be supported
var supportedLanguages = new List<string> var supportedLanguages = new List<string>