WIP: rework of localized strings, instead of generic LocStr, LocStr is now a struct which contains both the key, and the values which should be put into the value's placeholders. strs' properties are now methods which take values as arguments, and properties if they don't

This commit is contained in:
Kwoth
2021-07-26 20:08:02 +02:00
parent 9d375dccee
commit 0115d35247
46 changed files with 176 additions and 273 deletions

View File

@@ -107,7 +107,7 @@ namespace NadekoBot.Modules.Administration
public async Task PurgeUser(ulong userId)
{
var embed = _eb.Create()
.WithDescription(GetText(strs.purge_user_confirm, Format.Bold(userId.ToString())));
.WithDescription(GetText(strs.purge_user_confirm(Format.Bold(userId.ToString()))));
if (!await PromptUserConfirmAsync(embed).ConfigureAwait(false))
{

View File

@@ -133,7 +133,7 @@ namespace NadekoBot.Modules.Administration
return;
}
await SendConfirmAsync(GetText(strs.prot_enable, "Anti-Raid"),
await SendConfirmAsync(GetText(strs.prot_enable("Anti-Raid")),
$"{ctx.User.Mention} {GetAntiRaidString(stats)}")
.ConfigureAwait(false);
}
@@ -199,7 +199,7 @@ namespace NadekoBot.Modules.Administration
var stats = await _service.StartAntiSpamAsync(ctx.Guild.Id, messageCount, action, time, role?.Id).ConfigureAwait(false);
await SendConfirmAsync(GetText(strs.prot_enable, "Anti-Spam"),
await SendConfirmAsync(GetText(strs.prot_enable("Anti-Spam")),
$"{ctx.User.Mention} {GetAntiSpamString(stats)}").ConfigureAwait(false);
}
@@ -247,10 +247,10 @@ namespace NadekoBot.Modules.Administration
}
private string GetAntiAltString(AntiAltStats alt)
=> GetText(strs.anti_alt_status,
=> GetText(strs.anti_alt_status(
Format.Bold(alt.MinAge.ToString(@"dd\d\ hh\h\ mm\m\ ")),
Format.Bold(alt.Action.ToString()),
Format.Bold(alt.Counter.ToString()));
Format.Bold(alt.Counter.ToString())));
private string GetAntiSpamString(AntiSpamStats stats)
{

View File

@@ -150,7 +150,7 @@ namespace NadekoBot.Modules.Administration
}
var content = msg?.Content.TrimTo(30) ?? "DELETED!";
embed.AddField($"**{rr.Index + 1}.** {(ch?.Name ?? "DELETED!")}",
GetText(strs.reaction_roles_message, rr.ReactionRoles?.Count ?? 0, content));
GetText(strs.reaction_roles_message(rr.ReactionRoles?.Count ?? 0, content)));
}
}
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);

View File

@@ -128,7 +128,7 @@ namespace NadekoBot.Modules.Administration
var groupNameText = "";
if (!groups.TryGetValue(kvp.Key, out var name))
{
groupNameText = Format.Bold(GetText(strs.self_assign_group, kvp.Key));
groupNameText = Format.Bold(GetText(strs.self_assign_group(kvp.Key)));
}
else
{
@@ -155,7 +155,7 @@ namespace NadekoBot.Modules.Administration
}
return _eb.Create().WithOkColor()
.WithTitle(Format.Bold(GetText(strs.self_assign_list, roles.Count())))
.WithTitle(Format.Bold(GetText(strs.self_assign_list(roles.Count()))))
.WithDescription(rolesStr.ToString())
.WithFooter(exclusive
? GetText(strs.self_assign_are_exclusive)

View File

@@ -119,7 +119,7 @@ namespace NadekoBot.Modules.Administration
[{GetText(strs.channel)}]: {x.ChannelName} #{x.ChannelId}
[{GetText(strs.command_text)}]: {x.CommandText}```")),
title: string.Empty,
footer: GetText(strs.page, page + 1))
footer: GetText(strs.page(page + 1)))
.ConfigureAwait(false);
}
}
@@ -152,7 +152,7 @@ namespace NadekoBot.Modules.Administration
{GetIntervalText(x.Interval)}
[{GetText(strs.command_text)}]: {x.CommandText}```")),
title: string.Empty,
footer: GetText(strs.page, page + 1))
footer: GetText(strs.page(page + 1)))
.ConfigureAwait(false);
}
}

View File

@@ -61,7 +61,7 @@ namespace NadekoBot.Modules.Administration
try
{
await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).EmbedAsync(_eb.Create().WithErrorColor()
.WithDescription(GetText(strs.warned_on, ctx.Guild.ToString()))
.WithDescription(GetText(strs.warned_on(ctx.Guild.ToString())))
.AddField(GetText(strs.moderator), ctx.User.ToString())
.AddField(GetText(strs.reason), reason ?? "-"))
.ConfigureAwait(false);
@@ -101,7 +101,7 @@ namespace NadekoBot.Modules.Administration
}
else
{
embed.WithDescription(GetText(strs.user_warned_and_punished, Format.Bold(user.ToString()),
embed.WithDescription(GetText(strs.user_warned_and_punished(Format.Bold(user.ToString())),
Format.Bold(punishment.Punishment.ToString())));
}
@@ -221,7 +221,7 @@ namespace NadekoBot.Modules.Administration
var user = (ctx.Guild as SocketGuild)?.GetUser(userId)?.ToString() ?? userId.ToString();
var embed = _eb.Create()
.WithOkColor()
.WithTitle(GetText(strs.warnlog_for, user));
.WithTitle(GetText(strs.warnlog_for(user)));
if (!warnings.Any())
{
@@ -239,7 +239,7 @@ namespace NadekoBot.Modules.Administration
w.Moderator);
if (w.Forgiven)
name = $"{Format.Strikethrough(name)} {GetText(strs.warn_cleared_by, w.ForgivenBy)}";
name = $"{Format.Strikethrough(name)} {GetText(strs.warn_cleared_by(w.ForgivenBy))}";
embed.AddField($"#`{i}` " + name, w.Reason.TrimTo(1020));
}
@@ -436,7 +436,7 @@ namespace NadekoBot.Modules.Administration
{
try
{
var defaultMessage = GetText(strs.bandm, Format.Bold(ctx.Guild.Name), msg);
var defaultMessage = GetText(strs.bandm(Format.Bold(ctx.Guild.Name), msg));
var embed = _service.GetBanUserDmEmbed(Context, guildUser, defaultMessage, msg, time.Time);
if (embed is not null)
{
@@ -503,7 +503,7 @@ namespace NadekoBot.Modules.Administration
try
{
var defaultMessage = GetText(strs.bandm, Format.Bold(ctx.Guild.Name), msg);
var defaultMessage = GetText(strs.bandm(Format.Bold(ctx.Guild.Name), msg));
var embed = _service.GetBanUserDmEmbed(Context, user, defaultMessage, msg, null);
if (embed is not null)
{
@@ -584,7 +584,7 @@ namespace NadekoBot.Modules.Administration
private async Task InternalBanMessageTest(string reason, TimeSpan? duration)
{
var dmChannel = await ctx.User.GetOrCreateDMChannelAsync();
var defaultMessage = GetText(strs.bandm, Format.Bold(ctx.Guild.Name), reason);
var defaultMessage = GetText(strs.bandm(Format.Bold(ctx.Guild.Name), reason));
var embed = _service.GetBanUserDmEmbed(Context,
(IGuildUser)ctx.User,
defaultMessage,
@@ -685,7 +685,7 @@ namespace NadekoBot.Modules.Administration
try
{
await user.SendErrorAsync(_eb, GetText(strs.sbdm, Format.Bold(ctx.Guild.Name), msg)).ConfigureAwait(false);
await user.SendErrorAsync(_eb, GetText(strs.sbdm(Format.Bold(ctx.Guild.Name), msg)).ConfigureAwait(false));
}
catch
{
@@ -741,7 +741,7 @@ namespace NadekoBot.Modules.Administration
try
{
await user.SendErrorAsync(_eb, GetText(strs.kickdm, Format.Bold(ctx.Guild.Name), msg))
await user.SendErrorAsync(_eb, GetText(strs.kickdm(Format.Bold(ctx.Guild.Name), msg)))
.ConfigureAwait(false);
}
catch
@@ -783,8 +783,8 @@ namespace NadekoBot.Modules.Administration
//send a message but don't wait for it
var banningMessageTask = ctx.Channel.EmbedAsync(_eb.Create()
.WithDescription(GetText(strs.mass_kill_in_progress, bans.Count()))
.AddField(GetText(strs.invalid, missing), missStr)
.WithDescription(GetText(strs.mass_kill_in_progress(bans.Count())))
.AddField(GetText(strs.invalid(missing), missStr))
.WithOkColor());
//do the banning
@@ -800,8 +800,8 @@ namespace NadekoBot.Modules.Administration
var banningMessage = await banningMessageTask.ConfigureAwait(false);
await banningMessage.ModifyAsync(x => x.Embed = _eb.Create()
.WithDescription(GetText(strs.mass_kill_completed, bans.Count()))
.AddField(GetText(strs.invalid, missing), missStr)
.WithDescription(GetText(strs.mass_kill_completed(bans.Count())))
.AddField(GetText(strs.invalid(missing), missStr))
.WithOkColor()
.Build()).ConfigureAwait(false);
}