From 8408a17450f3a74bfcda35b846319b9cd0829653 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Mon, 8 May 2017 13:43:38 +0200 Subject: [PATCH] Moved _strings, added some extension methods --- src/NadekoBot/Modules/Help/Help.cs | 4 ++-- src/NadekoBot/NadekoBot.csproj | 3 +++ src/NadekoBot/Services/NadekoStrings.cs | 2 +- src/NadekoBot/_Extensions/Extensions.cs | 3 +++ .../{data/strings => _strings}/ResponseStrings.ar.json | 0 .../{data/strings => _strings}/ResponseStrings.en-US.json | 0 .../{data/strings => _strings}/ResponseStrings.es-ES.json | 0 .../{data/strings => _strings}/ResponseStrings.he-IL.json | 0 .../{data/strings => _strings}/ResponseStrings.id-ID.json | 0 .../{data/strings => _strings}/ResponseStrings.it-IT.json | 0 .../{data/strings => _strings}/ResponseStrings.ja-JP.json | 0 .../{data/strings => _strings}/ResponseStrings.ko-KR.json | 0 .../{data/strings => _strings}/ResponseStrings.nb-NO.json | 0 .../{data/strings => _strings}/ResponseStrings.pl-PL.json | 0 .../{data/strings => _strings}/ResponseStrings.pt-BR.json | 0 .../{data/strings => _strings}/ResponseStrings.ru-RU.json | 0 .../strings => _strings}/ResponseStrings.sr-cyrl-rs.json | 0 .../{data/strings => _strings}/ResponseStrings.sv-SE.json | 0 .../{data/strings => _strings}/ResponseStrings.tr-TR.json | 0 .../{data/strings => _strings}/ResponseStrings.zh-CN.json | 0 .../{data/strings => _strings}/ResponseStrings.zh-TW.json | 0 21 files changed, 9 insertions(+), 3 deletions(-) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.ar.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.en-US.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.es-ES.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.he-IL.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.id-ID.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.it-IT.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.ja-JP.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.ko-KR.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.nb-NO.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.pl-PL.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.pt-BR.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.ru-RU.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.sr-cyrl-rs.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.sv-SE.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.tr-TR.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.zh-CN.json (100%) rename src/NadekoBot/{data/strings => _strings}/ResponseStrings.zh-TW.json (100%) diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index 1208260b..c0948041 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -93,8 +93,8 @@ namespace NadekoBot.Modules.Help if (alias != null) str += string.Format(" **/ `{0}`**", alias); var embed = new EmbedBuilder() - .AddField(fb => fb.WithName(str).WithValue($"{string.Format(com.Summary, com.Module.Aliases.First())} {GetCommandRequirements(com)}").WithIsInline(true)) - .AddField(fb => fb.WithName(GetText("usage")).WithValue(string.Format(com.Remarks, com.Module.Aliases.First())).WithIsInline(false)) + .AddField(fb => fb.WithName(str).WithValue($"{com.RealSummary()} {GetCommandRequirements(com)}").WithIsInline(true)) + .AddField(fb => fb.WithName(GetText("usage")).WithValue(com.RealRemarks()).WithIsInline(false)) .WithColor(NadekoBot.OkColor); await channel.EmbedAsync(embed).ConfigureAwait(false); } diff --git a/src/NadekoBot/NadekoBot.csproj b/src/NadekoBot/NadekoBot.csproj index 2812273a..2d574796 100644 --- a/src/NadekoBot/NadekoBot.csproj +++ b/src/NadekoBot/NadekoBot.csproj @@ -34,6 +34,9 @@ PreserveNewest + + Always + Never diff --git a/src/NadekoBot/Services/NadekoStrings.cs b/src/NadekoBot/Services/NadekoStrings.cs index cd497d31..5bad0214 100644 --- a/src/NadekoBot/Services/NadekoStrings.cs +++ b/src/NadekoBot/Services/NadekoStrings.cs @@ -11,7 +11,7 @@ namespace NadekoBot.Services { public class NadekoStrings { - public const string stringsPath = @"data/strings/"; + public const string stringsPath = @"_strings/"; private readonly ImmutableDictionary> responseStrings; private readonly Logger _log; diff --git a/src/NadekoBot/_Extensions/Extensions.cs b/src/NadekoBot/_Extensions/Extensions.cs index 778399dd..bc72a25a 100644 --- a/src/NadekoBot/_Extensions/Extensions.cs +++ b/src/NadekoBot/_Extensions/Extensions.cs @@ -27,6 +27,9 @@ namespace NadekoBot.Extensions return Convert.ToBase64String(plainTextBytes); } + public static string RealSummary(this CommandInfo cmd) => string.Format(cmd.Summary, cmd.Module.GetTopLevelModule().Prefix); + public static string RealRemarks(this CommandInfo cmd) => string.Format(cmd.Remarks, cmd.Module.GetTopLevelModule().Prefix); + public static Stream ToStream(this IEnumerable bytes, bool canWrite = false) { var ms = new MemoryStream(bytes as byte[] ?? bytes.ToArray(), canWrite); diff --git a/src/NadekoBot/data/strings/ResponseStrings.ar.json b/src/NadekoBot/_strings/ResponseStrings.ar.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.ar.json rename to src/NadekoBot/_strings/ResponseStrings.ar.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.en-US.json b/src/NadekoBot/_strings/ResponseStrings.en-US.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.en-US.json rename to src/NadekoBot/_strings/ResponseStrings.en-US.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.es-ES.json b/src/NadekoBot/_strings/ResponseStrings.es-ES.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.es-ES.json rename to src/NadekoBot/_strings/ResponseStrings.es-ES.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.he-IL.json b/src/NadekoBot/_strings/ResponseStrings.he-IL.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.he-IL.json rename to src/NadekoBot/_strings/ResponseStrings.he-IL.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.id-ID.json b/src/NadekoBot/_strings/ResponseStrings.id-ID.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.id-ID.json rename to src/NadekoBot/_strings/ResponseStrings.id-ID.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.it-IT.json b/src/NadekoBot/_strings/ResponseStrings.it-IT.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.it-IT.json rename to src/NadekoBot/_strings/ResponseStrings.it-IT.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.ja-JP.json b/src/NadekoBot/_strings/ResponseStrings.ja-JP.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.ja-JP.json rename to src/NadekoBot/_strings/ResponseStrings.ja-JP.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.ko-KR.json b/src/NadekoBot/_strings/ResponseStrings.ko-KR.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.ko-KR.json rename to src/NadekoBot/_strings/ResponseStrings.ko-KR.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.nb-NO.json b/src/NadekoBot/_strings/ResponseStrings.nb-NO.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.nb-NO.json rename to src/NadekoBot/_strings/ResponseStrings.nb-NO.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.pl-PL.json b/src/NadekoBot/_strings/ResponseStrings.pl-PL.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.pl-PL.json rename to src/NadekoBot/_strings/ResponseStrings.pl-PL.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.pt-BR.json b/src/NadekoBot/_strings/ResponseStrings.pt-BR.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.pt-BR.json rename to src/NadekoBot/_strings/ResponseStrings.pt-BR.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.ru-RU.json b/src/NadekoBot/_strings/ResponseStrings.ru-RU.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.ru-RU.json rename to src/NadekoBot/_strings/ResponseStrings.ru-RU.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.sr-cyrl-rs.json b/src/NadekoBot/_strings/ResponseStrings.sr-cyrl-rs.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.sr-cyrl-rs.json rename to src/NadekoBot/_strings/ResponseStrings.sr-cyrl-rs.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.sv-SE.json b/src/NadekoBot/_strings/ResponseStrings.sv-SE.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.sv-SE.json rename to src/NadekoBot/_strings/ResponseStrings.sv-SE.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.tr-TR.json b/src/NadekoBot/_strings/ResponseStrings.tr-TR.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.tr-TR.json rename to src/NadekoBot/_strings/ResponseStrings.tr-TR.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.zh-CN.json b/src/NadekoBot/_strings/ResponseStrings.zh-CN.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.zh-CN.json rename to src/NadekoBot/_strings/ResponseStrings.zh-CN.json diff --git a/src/NadekoBot/data/strings/ResponseStrings.zh-TW.json b/src/NadekoBot/_strings/ResponseStrings.zh-TW.json similarity index 100% rename from src/NadekoBot/data/strings/ResponseStrings.zh-TW.json rename to src/NadekoBot/_strings/ResponseStrings.zh-TW.json