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

@@ -11,99 +11,33 @@ using Newtonsoft.Json;
namespace NadekoBot.Generators
{
internal class FieldData
internal class TranslationPair
{
public string Type { get; set; }
public string Name { get; set; }
public string Value { get; set; }
}
[Generator]
public class LocalizedStringsGenerator : ISourceGenerator
{
private const string LocStrSource = @"namespace NadekoBot
{
public readonly ref struct LocStr0
public readonly struct LocStr
{
public readonly string Key;
public readonly object[] Parms;
public LocStr0(string key)
public LocStr(string key, params object[] data)
{
Key = key;
Params = data;
}
public static implicit operator LocStr0(string data)
=> new LocStr0(data);
}
public readonly ref struct LocStr1
{
public readonly string Key;
public LocStr1(string key)
{
Key = key;
}
public static implicit operator LocStr1(string data)
=> new LocStr1(data);
}
public readonly ref struct LocStr2
{
public readonly string Key;
public LocStr2(string key)
{
Key = key;
}
public static implicit operator LocStr2(string data)
=> new LocStr2(data);
}
public readonly ref struct LocStr3
{
public readonly string Key;
public LocStr3(string key)
{
Key = key;
}
public static implicit operator LocStr3(string data)
=> new LocStr3(data);
}
public readonly ref struct LocStr4
{
public readonly string Key;
public LocStr4(string key)
{
Key = key;
}
public static implicit operator LocStr4(string data)
=> new LocStr4(data);
}
public readonly ref struct LocStr5
{
public readonly string Key;
public LocStr5(string key)
{
Key = key;
}
public static implicit operator LocStr5(string data)
=> new LocStr5(data);
}
}";
public void Initialize(GeneratorInitializationContext context)
{
}
public void Execute(GeneratorExecutionContext context)
@@ -125,66 +59,60 @@ namespace NadekoBot.Generators
foreach (var field in fields)
{
sw.WriteLine($"public static {field.Type} {field.Name} => \"{field.Name}\";");
var matches = Regex.Matches(field.Value, @"{(?<num>\d)}");
var max = 0;
foreach (Match match in matches)
{
max = Math.Max(max, int.Parse(match.Groups["num"].Value) + 1);
}
List<string> typedParamStrings = new List<string>();
var paramStrings = string.Empty;
for (var i = 0; i < max; i++)
{
typedParamStrings.Add($"object p{i}");
paramStrings += $", p{i}";
}
var sig = string.Empty;
if(max > 0)
sig = $"({string.Join(", ", typedParamStrings)})";
sw.WriteLine($"public static LocStr {field.Name}{sig} => new LocStr(\"{field.Name}\"{paramStrings});");
}
sw.Indent--;
sw.WriteLine("}");
sw.Indent--;
sw.WriteLine("}");
sw.Flush();
context.AddSource("strs.cs", stringWriter.ToString());
}
context.AddSource("LocStr.cs", LocStrSource);
}
private List<FieldData> GetFields(string dataText)
private List<TranslationPair> GetFields(string dataText)
{
if (string.IsNullOrWhiteSpace(dataText))
throw new ArgumentNullException(nameof(dataText));
var data = JsonConvert.DeserializeObject<Dictionary<string, string>>(dataText);
var list = new List<FieldData>();
var list = new List<TranslationPair>();
foreach (var entry in data)
{
list.Add(new FieldData()
list.Add(new TranslationPair()
{
Type = GetFieldType(entry.Value),
Name = entry.Key,
Value = entry.Value
});
}
return list;
}
private string GetFieldType(string value)
{
var matches = Regex.Matches(value, @"{(?<num>\d)}");
int max = -1;
foreach (Match match in matches)
{
max = Math.Max(max, int.Parse(match.Groups["num"].Value));
}
max += 1;
if (max == 0)
return "LocStr0";
if (max == 1)
return "LocStr1";
if (max == 2)
return "LocStr2";
if (max == 3)
return "LocStr3";
if (max == 4)
return "LocStr4";
if (max == 5)
return "LocStr5";
return "!Error";
}
}
}

View File

@@ -33,23 +33,8 @@ namespace NadekoBot.Modules
protected string GetText(string key) =>
Strings.GetText(key, _cultureInfo);
protected string GetText(in LocStr0 key) =>
Strings.GetText(key, _cultureInfo);
protected string GetText(in LocStr1 key, object obj1) =>
Strings.GetText(key, _cultureInfo, obj1);
protected string GetText(in LocStr2 key, object obj1, object obj2) =>
Strings.GetText(key, _cultureInfo, obj1, obj2);
protected string GetText(in LocStr3 key, object obj1, object obj2, object obj3) =>
Strings.GetText(key, _cultureInfo, obj1, obj2, obj3);
protected string GetText(in LocStr4 key, object obj1, object obj2, object obj3, object obj4) =>
Strings.GetText(key, _cultureInfo, obj1, obj2, obj3, obj4);
protected string GetText(in LocStr5 key, object obj1, object obj2, object obj3, object obj4, object obj5) =>
Strings.GetText(key, _cultureInfo, obj1, obj2, obj3, obj4, obj5);
protected string GetText(in LocStr data) =>
Strings.GetText(data, _cultureInfo);
protected string GetText(string key, params object[] args) =>
Strings.GetText(key, _cultureInfo, args);

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);
}

View File

@@ -77,13 +77,13 @@ namespace NadekoBot.Modules.Gambling
if (race.FinishedUsers[0].Bet > 0)
{
return SendConfirmAsync(GetText(strs.animal_race),
GetText(strs.animal_race_won_money, Format.Bold(winner.Username),
GetText(strs.animal_race_won_money(Format.Bold(winner.Username)),
winner.Animal.Icon, (race.FinishedUsers[0].Bet * (race.Users.Count - 1)) + CurrencySign));
}
else
{
return SendConfirmAsync(GetText(strs.animal_race),
GetText(strs.animal_race_won, Format.Bold(winner.Username), winner.Animal.Icon));
GetText(strs.animal_race_won(Format.Bold(winner.Username), winner.Animal.Icon)));
}
}
@@ -93,8 +93,8 @@ namespace NadekoBot.Modules.Gambling
ar.OnStarted += Ar_OnStarted;
_client.MessageReceived += _client_MessageReceived;
return SendConfirmAsync(GetText(strs.animal_race), GetText(strs.animal_race_starting, options.StartTime),
footer: GetText(strs.animal_race_join_instr, Prefix));
return SendConfirmAsync(GetText(strs.animal_race), GetText(strs.animal_race_starting(options.StartTime)),
footer: GetText(strs.animal_race_join_instr(Prefix)));
}
private Task Ar_OnStarted(AnimalRace race)
@@ -102,7 +102,7 @@ namespace NadekoBot.Modules.Gambling
if (race.Users.Count == race.MaxUsers)
return SendConfirmAsync(GetText(strs.animal_race), GetText(strs.animal_race_full));
else
return SendConfirmAsync(GetText(strs.animal_race), GetText(strs.animal_race_starting_with_x, race.Users.Count));
return SendConfirmAsync(GetText(strs.animal_race), GetText(strs.animal_race_starting_with_x(race.Users.Count)));
}
private async Task Ar_OnStateUpdate(AnimalRace race)
@@ -153,9 +153,9 @@ namespace NadekoBot.Modules.Gambling
var user = await ar.JoinRace(ctx.User.Id, ctx.User.ToString(), amount)
.ConfigureAwait(false);
if (amount > 0)
await SendConfirmAsync(GetText(strs.animal_race_join_bet, ctx.User.Mention, user.Animal.Icon, amount + CurrencySign)).ConfigureAwait(false);
await SendConfirmAsync(GetText(strs.animal_race_join_bet(ctx.User.Mention, user.Animal.Icon, amount + CurrencySign)).ConfigureAwait(false));
else
await SendConfirmAsync(GetText(strs.animal_race_join, ctx.User.Mention, user.Animal.Icon)).ConfigureAwait(false);
await SendConfirmAsync(GetText(strs.animal_race_join(ctx.User.Mention, user.Animal.Icon)).ConfigureAwait(false));
}
catch (ArgumentOutOfRangeException)
{
@@ -176,7 +176,7 @@ namespace NadekoBot.Modules.Gambling
}
catch (NotEnoughFundsException)
{
await SendErrorAsync(GetText(strs.not_enough, CurrencySign)).ConfigureAwait(false);
await SendErrorAsync(GetText(strs.not_enough(CurrencySign)).ConfigureAwait(false));
}
}
}

View File

@@ -129,11 +129,11 @@ namespace NadekoBot.Modules.Gambling
string title;
if (result == Connect4Game.Result.CurrentPlayerWon)
{
title = GetText(strs.connect4_won, Format.Bold(arg.CurrentPlayer.Username), Format.Bold(arg.OtherPlayer.Username));
title = GetText(strs.connect4_won(Format.Bold(arg.CurrentPlayer.Username), Format.Bold(arg.OtherPlayer.Username)));
}
else if (result == Connect4Game.Result.OtherPlayerWon)
{
title = GetText(strs.connect4_won, Format.Bold(arg.OtherPlayer.Username), Format.Bold(arg.CurrentPlayer.Username));
title = GetText(strs.connect4_won(Format.Bold(arg.OtherPlayer.Username), Format.Bold(arg.CurrentPlayer.Username)));
}
else
title = GetText(strs.connect4_draw);
@@ -180,7 +180,7 @@ namespace NadekoBot.Modules.Gambling
if (game.CurrentPhase == Connect4Game.Phase.P1Move ||
game.CurrentPhase == Connect4Game.Phase.P2Move)
sb.AppendLine(GetText(strs.connect4_player_to_move, Format.Bold(game.CurrentPlayer.Username)));
sb.AppendLine(GetText(strs.connect4_player_to_move(Format.Bold(game.CurrentPlayer.Username))));
for (int i = Connect4Game.NumberOfRows; i > 0; i--)
{

View File

@@ -52,15 +52,15 @@ namespace NadekoBot.Modules.Gambling
case CurrencyEvent.Type.Reaction:
return _eb.Create()
.WithOkColor()
.WithTitle(GetText(strs.event_title, type.ToString()))
.WithTitle(GetText(strs.event_title(type.ToString())))
.WithDescription(GetReactionDescription(opts.Amount, currentPot))
.WithFooter(GetText(strs.event_duration_footer, opts.Hours));
.WithFooter(GetText(strs.event_duration_footer(opts.Hours)));
case CurrencyEvent.Type.GameStatus:
return _eb.Create()
.WithOkColor()
.WithTitle(GetText(strs.event_title, type.ToString()))
.WithTitle(GetText(strs.event_title(type.ToString())))
.WithDescription(GetGameStatusDescription(opts.Amount, currentPot))
.WithFooter(GetText(strs.event_duration_footer, opts.Hours));
.WithFooter(GetText(strs.event_duration_footer(opts.Hours)));
default:
break;
}

View File

@@ -35,7 +35,7 @@ namespace NadekoBot.Modules.Gambling
return;
async Task OnEnded(IUser arg, long won)
{
await SendConfirmAsync(GetText(strs.rafflecur_ended, CurrencyName, Format.Bold(arg.ToString()), won + CurrencySign)).ConfigureAwait(false);
await SendConfirmAsync(GetText(strs.rafflecur_ended(CurrencyName, Format.Bold(arg.ToString()), won + CurrencySign)).ConfigureAwait(false));
}
var res = await _service.JoinOrCreateGame(ctx.Channel.Id,
ctx.User, amount, mixed, OnEnded)
@@ -43,9 +43,9 @@ namespace NadekoBot.Modules.Gambling
if (res.Item1 != null)
{
await SendConfirmAsync(GetText(strs.rafflecur, res.Item1.GameType.ToString()),
await SendConfirmAsync(GetText(strs.rafflecur(res.Item1.GameType.ToString())),
string.Join("\n", res.Item1.Users.Select(x => $"{x.DiscordUser} ({x.Amount})")),
footer: GetText(strs.rafflecur_joined, ctx.User.ToString())).ConfigureAwait(false);
footer: GetText(strs.rafflecur_joined(ctx.User.ToString())).ConfigureAwait(false));
}
else
{

View File

@@ -47,7 +47,7 @@ namespace NadekoBot.Modules.Gambling
{
await ctx.Channel.SendFileAsync(ms,
$"dice.{format.FileExtensions.First()}",
Format.Bold(ctx.User.ToString()) + " " + GetText(strs.dice_rolled, Format.Code(gen.ToString()))).ConfigureAwait(false);
Format.Bold(ctx.User.ToString()) + " " + GetText(strs.dice_rolled(Format.Code(gen.ToString()))).ConfigureAwait(false));
}
}
@@ -128,7 +128,7 @@ namespace NadekoBot.Modules.Gambling
await ctx.Channel.SendFileAsync(ms, $"dice.{format.FileExtensions.First()}",
Format.Bold(ctx.User.ToString()) + " " +
GetText(strs.dice_rolled_num, Format.Bold(values.Count.ToString())) +
GetText(strs.dice_rolled_num(Format.Bold(values.Count.ToString()))) +
" " + GetText(strs.total_average,
Format.Bold(values.Sum().ToString()),
Format.Bold((values.Sum() / (1.0f * values.Count)).ToString("N2")))).ConfigureAwait(false);
@@ -152,7 +152,7 @@ namespace NadekoBot.Modules.Gambling
}
var embed = _eb.Create()
.WithOkColor()
.WithDescription(ctx.User.Mention + " " + GetText(strs.dice_rolled_num, Format.Bold(n1.ToString())))
.WithDescription(ctx.User.Mention + " " + GetText(strs.dice_rolled_num(Format.Bold(n1.ToString()))))
.AddField(Format.Bold("Result"), string.Join(" ", rolls.Select(c => Format.Code($"[{c}]"))));
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
@@ -177,7 +177,7 @@ namespace NadekoBot.Modules.Gambling
var sum = arr.Sum();
var embed = _eb.Create().WithOkColor()
.WithDescription(ctx.User.Mention + " " + GetText(strs.dice_rolled_num, n1) + $"`1 - {n2}`")
.WithDescription(ctx.User.Mention + " " + GetText(strs.dice_rolled_num(n1) + $"`1 - {n2}`"))
.AddField(Format.Bold("Rolls"), string.Join(" ",
(ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x =>
Format.Code(x.ToString()))))

View File

@@ -66,7 +66,7 @@ namespace NadekoBot.Modules.Gambling
toSend += $" drew `{Deck.GetHandValue(cardObjects)}`";
if (guildId != null)
toSend += "\n" + GetText(strs.cards_left, Format.Bold(cards.CardPool.Count.ToString()));
toSend += "\n" + GetText(strs.cards_left(Format.Bold(cards.CardPool.Count.ToString())));
return (img.ToStream(), toSend);
}

View File

@@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Gambling
i.Dispose();
}
var msg = count != 1
? Format.Bold(ctx.User.ToString()) + " " + GetText(strs.flip_results, count, headCount, tailCount)
? Format.Bold(ctx.User.ToString()) + " " + GetText(strs.flip_results(count, headCount, tailCount))
: Format.Bold(ctx.User.ToString()) + " " + GetText(strs.flipped, headCount > 0
? Format.Bold(GetText(strs.heads))
: Format.Bold(GetText(strs.tails)));
@@ -115,7 +115,7 @@ namespace NadekoBot.Modules.Gambling
if (guess == result)
{
var toWin = (long)(amount * _config.BetFlip.Multiplier);
str = Format.Bold(ctx.User.ToString()) + " " + GetText(strs.flip_guess, toWin + CurrencySign);
str = Format.Bold(ctx.User.ToString()) + " " + GetText(strs.flip_guess(toWin + CurrencySign));
await _cs.AddAsync(ctx.User, "Betflip Gamble", toWin, false, gamble: true).ConfigureAwait(false);
}
else

View File

@@ -209,7 +209,7 @@ namespace NadekoBot.Modules.Gambling
}
embed.WithDescription(desc);
embed.WithFooter(GetText(strs.page, page + 1));
embed.WithFooter(GetText(strs.page(page + 1)));
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
}
@@ -476,7 +476,7 @@ namespace NadekoBot.Modules.Gambling
var result = br.Roll();
var str = Format.Bold(ctx.User.ToString()) + Format.Code(GetText(strs.roll, result.Roll));
var str = Format.Bold(ctx.User.ToString()) + Format.Code(GetText(strs.roll(result.Roll)));
if (result.Multiplier > 0)
{
var win = (long)(amount * result.Multiplier);
@@ -641,7 +641,7 @@ namespace NadekoBot.Modules.Gambling
await _cs.AddAsync(ctx.User.Id,
"Rps-draw", amount, gamble: true).ConfigureAwait(false);
embed.WithOkColor();
msg = GetText(strs.rps_draw, getRpsPick(pick));
msg = GetText(strs.rps_draw(getRpsPick(pick)));
}
else if ((pick == RpsPick.Paper && nadekoPick == RpsPick.Rock) ||
(pick == RpsPick.Rock && nadekoPick == RpsPick.Scissors) ||
@@ -659,7 +659,7 @@ namespace NadekoBot.Modules.Gambling
{
embed.WithErrorColor();
amount = 0;
msg = GetText(strs.rps_win, ctx.Client.CurrentUser.Mention, getRpsPick(nadekoPick),
msg = GetText(strs.rps_win(ctx.Client.CurrentUser.Mention, getRpsPick(nadekoPick)),
getRpsPick(pick));
}

View File

@@ -173,7 +173,7 @@ namespace NadekoBot.Modules.Gambling
{
await (await ctx.User.GetOrCreateDMChannelAsync().ConfigureAwait(false))
.EmbedAsync(_eb.Create().WithOkColor()
.WithTitle(GetText(strs.shop_purchase, ctx.Guild.Name))
.WithTitle(GetText(strs.shop_purchase(ctx.Guild.Name)))
.AddField(GetText(strs.item), item.Text, false)
.AddField(GetText(strs.price), entry.Price.ToString(), true)
.AddField(GetText(strs.name), entry.Name, true))
@@ -433,7 +433,7 @@ namespace NadekoBot.Modules.Gambling
var embed = _eb.Create().WithOkColor();
if (entry.Type == ShopEntryType.Role)
return embed.AddField(GetText(strs.name), GetText(strs.shop_role, Format.Bold(ctx.Guild.GetRole(entry.RoleId)?.Name ?? "MISSING_ROLE")), true)
return embed.AddField(GetText(strs.name), GetText(strs.shop_role(Format.Bold(ctx.Guild.GetRole(entry.RoleId)?.Name ?? "MISSING_ROLE")), true))
.AddField(GetText(strs.price), entry.Price.ToString(), true)
.AddField(GetText(strs.type), entry.Type.ToString(), true);
else if (entry.Type == ShopEntryType.List)
@@ -441,7 +441,7 @@ namespace NadekoBot.Modules.Gambling
.AddField(GetText(strs.price), entry.Price.ToString(), true)
.AddField(GetText(strs.type), GetText(strs.random_unique_item), true);
//else if (entry.Type == ShopEntryType.Infinite_List)
// return embed.AddField(GetText(strs.name), GetText(strs.shop_role, Format.Bold(entry.RoleName)), true)
// return embed.AddField(GetText(strs.name), GetText(strs.shop_role(Format.Bold(entry.RoleName)), true))
// .AddField(GetText(strs.price), entry.Price.ToString(), true)
// .AddField(GetText(strs.type), entry.Type.ToString(), true);
else return null;
@@ -451,11 +451,11 @@ namespace NadekoBot.Modules.Gambling
{
if (entry.Type == ShopEntryType.Role)
{
return GetText(strs.shop_role, Format.Bold(ctx.Guild.GetRole(entry.RoleId)?.Name ?? "MISSING_ROLE"));
return GetText(strs.shop_role(Format.Bold(ctx.Guild.GetRole(entry.RoleId)?.Name ?? "MISSING_ROLE")));
}
else if (entry.Type == ShopEntryType.List)
{
return GetText(strs.unique_items_left, entry.Items.Count) + "\n" + entry.Name;
return GetText(strs.unique_items_left(entry.Items.Count)) + "\n" + entry.Name;
}
//else if (entry.Type == ShopEntryType.Infinite_List)
//{

View File

@@ -203,13 +203,13 @@ namespace NadekoBot.Modules.Gambling
await _cs.AddAsync(ctx.User, $"Slot Machine x{result.Multiplier}", amount * result.Multiplier, false, gamble: true).ConfigureAwait(false);
Interlocked.Add(ref _totalPaidOut, amount * result.Multiplier);
if (result.Multiplier == 1)
msg = GetText(strs.slot_single, CurrencySign, 1);
msg = GetText(strs.slot_single(CurrencySign, 1));
else if (result.Multiplier == 4)
msg = GetText(strs.slot_two, CurrencySign, 4);
msg = GetText(strs.slot_two(CurrencySign, 4));
else if (result.Multiplier == 10)
msg = GetText(strs.slot_three, 10);
msg = GetText(strs.slot_three(10));
else if (result.Multiplier == 30)
msg = GetText(strs.slot_jackpot, 30);
msg = GetText(strs.slot_jackpot(30));
}
using (var imgStream = bgImage.ToStream())

View File

@@ -27,7 +27,7 @@ namespace NadekoBot.Modules.Gambling
var price = _service.GetResetPrice(ctx.User);
var embed = _eb.Create()
.WithTitle(GetText(strs.waifu_reset_confirm))
.WithDescription(GetText(strs.waifu_reset_price, Format.Bold(price + CurrencySign)));
.WithDescription(GetText(strs.waifu_reset_price(Format.Bold(price + CurrencySign))));
if (!await PromptUserConfirmAsync(embed))
return;
@@ -72,7 +72,7 @@ namespace NadekoBot.Modules.Gambling
Format.Bold(target.ToString()),
amount + CurrencySign);
if (w.Affinity?.UserId == ctx.User.Id)
msg += "\n" + GetText(strs.waifu_fulfilled, target, w.Price + CurrencySign);
msg += "\n" + GetText(strs.waifu_fulfilled(target, w.Price + CurrencySign));
else
msg = " " + msg;
await SendConfirmAsync(ctx.User.Mention + msg);
@@ -292,7 +292,7 @@ namespace NadekoBot.Modules.Gambling
.AddField(GetText(strs.changes_of_heart), $"{wi.AffinityCount} - \"the {affInfo}\"", true)
.AddField(GetText(strs.divorces), wi.DivorceCount.ToString(), true)
.AddField("\u200B", "\u200B", true)
.AddField(GetText(strs.fans, wi.Fans.Count), fansStr, true)
.AddField(GetText(strs.fans(wi.Fans.Count), fansStr, true))
.AddField($"Waifus ({wi.ClaimCount})", wi.ClaimCount == 0
? nobody
: string.Join("\n", wi.Claims.Shuffle().Take(30)), true)

View File

@@ -82,8 +82,8 @@ namespace NadekoBot.Modules.Games
{
var embed = _eb.Create().WithOkColor()
.WithTitle(GetText(strs.acrophobia))
.WithDescription(GetText(strs.acro_started, Format.Bold(string.Join(".", game.StartingLetters))))
.WithFooter(GetText(strs.acro_started_footer, game.Opts.SubmissionTime));
.WithDescription(GetText(strs.acro_started(Format.Bold(string.Join(".", game.StartingLetters)))))
.WithFooter(GetText(strs.acro_started_footer(game.Opts.SubmissionTime)));
return ctx.Channel.EmbedAsync(embed);
}
@@ -92,7 +92,7 @@ namespace NadekoBot.Modules.Games
{
return SendConfirmAsync(
GetText(strs.acrophobia),
GetText(strs.acro_vote_cast, Format.Bold(user)));
GetText(strs.acro_vote_cast(Format.Bold(user))));
}
private async Task Game_OnVotingStarted(AcrophobiaGame game, ImmutableArray<KeyValuePair<AcrophobiaUser, int>> submissions)
@@ -118,7 +118,7 @@ namespace NadekoBot.Modules.Games
var embed = _eb.Create()
.WithOkColor()
.WithTitle(GetText(strs.acrophobia) + " - " + GetText(strs.submissions_closed))
.WithDescription(GetText(strs.acro_nym_was, Format.Bold(string.Join(".", game.StartingLetters)) + "\n" +
.WithDescription(GetText(strs.acro_nym_was(Format.Bold(string.Join(".", game.StartingLetters))) + "\n" +
$@"--
{submissions.Aggregate("", (agg, cur) => agg + $"`{++i}.` **{cur.Key.Input}**\n")}
--"))
@@ -138,7 +138,7 @@ $@"--
var winner = table.First();
var embed = _eb.Create().WithOkColor()
.WithTitle(GetText(strs.acrophobia))
.WithDescription(GetText(strs.acro_winner, Format.Bold(winner.Key.UserName),
.WithDescription(GetText(strs.acro_winner(Format.Bold(winner.Key.UserName)),
Format.Bold(winner.Value.ToString())))
.WithFooter(winner.Key.Input);

View File

@@ -74,12 +74,6 @@ namespace NadekoBot.Modules.Games.Common
private string GetText(LocStr key)
=> _strings.GetText(key, _channel.GuildId);
private string GetText<T>(LocStr<T> key, T param)
=> _strings.GetText(key, _channel.GuildId, param);
private string GetText<T1, T2>(LocStr<T1, T2> key, T1 param, T2 param2)
=> _strings.GetText(key, _channel.GuildId, param, param2);
public string GetState()
{
@@ -104,7 +98,7 @@ namespace NadekoBot.Modules.Games.Common
var embed = _eb.Create()
.WithOkColor()
.WithDescription(Environment.NewLine + GetState())
.WithAuthor(GetText(strs.vs, _users[0], _users[1]));
.WithAuthor(GetText(strs.vs(_users[0], _users[1])));
if (!string.IsNullOrWhiteSpace(title))
embed.WithTitle(title);
@@ -114,10 +108,10 @@ namespace NadekoBot.Modules.Games.Common
if (_phase == Phase.Ended)
embed.WithFooter(GetText(strs.ttt_no_moves));
else
embed.WithFooter(GetText(strs.ttt_users_move, _users[_curUserIndex]));
embed.WithFooter(GetText(strs.ttt_users_move(_users[_curUserIndex])));
}
else
embed.WithFooter(GetText(strs.ttt_has_won, _winner));
embed.WithFooter(GetText(strs.ttt_has_won(_winner)));
return embed;
}

View File

@@ -64,12 +64,6 @@ namespace NadekoBot.Modules.Games.Common.Trivia
private string GetText(in LocStr key)
=> _strings.GetText(key, Channel.GuildId);
private string GetText<T>(in LocStr<T> key, T param1)
=> _strings.GetText(key, Channel.GuildId, param1);
private string GetText<T1, T2>(in LocStr<T1, T2> key, T1 param1, T2 param2)
=> _strings.GetText(key, Channel.GuildId, param1, param2);
public async Task StartGame()
{
@@ -99,7 +93,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
.AddField(GetText(strs.question), CurrentQuestion.Question);
if (showHowToQuit)
questionEmbed.WithFooter(GetText(strs.trivia_quit, _quitCommand));
questionEmbed.WithFooter(GetText(strs.trivia_quit(_quitCommand)));
if (Uri.IsWellFormedUriString(CurrentQuestion.ImageUrl, UriKind.Absolute))
questionEmbed.WithImageUrl(CurrentQuestion.ImageUrl);
@@ -159,7 +153,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
{
var embed = _eb.Create().WithErrorColor()
.WithTitle(GetText(strs.trivia_game))
.WithDescription(GetText(strs.trivia_times_up, Format.Bold(CurrentQuestion.Answer)));
.WithDescription(GetText(strs.trivia_times_up(Format.Bold(CurrentQuestion.Answer))));
if (Uri.IsWellFormedUriString(CurrentQuestion.AnswerImageUrl, UriKind.Absolute))
embed.WithImageUrl(CurrentQuestion.AnswerImageUrl);
@@ -246,9 +240,9 @@ namespace NadekoBot.Modules.Games.Common.Trivia
{
var embedS = _eb.Create().WithOkColor()
.WithTitle(GetText(strs.trivia_game))
.WithDescription(GetText(strs.trivia_win,
.WithDescription(GetText(strs.trivia_win(
guildUser.Mention,
Format.Bold(CurrentQuestion.Answer)));
Format.Bold(CurrentQuestion.Answer))));
if (Uri.IsWellFormedUriString(CurrentQuestion.AnswerImageUrl, UriKind.Absolute))
embedS.WithImageUrl(CurrentQuestion.AnswerImageUrl);
await Channel.EmbedAsync(embedS).ConfigureAwait(false);
@@ -264,7 +258,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
}
var embed = _eb.Create().WithOkColor()
.WithTitle(GetText(strs.trivia_game))
.WithDescription(GetText(strs.trivia_guess, guildUser.Mention, Format.Bold(CurrentQuestion.Answer)));
.WithDescription(GetText(strs.trivia_guess(guildUser.Mention, Format.Bold(CurrentQuestion.Answer))));
if (Uri.IsWellFormedUriString(CurrentQuestion.AnswerImageUrl, UriKind.Absolute))
embed.WithImageUrl(CurrentQuestion.AnswerImageUrl);
await Channel.EmbedAsync(embed).ConfigureAwait(false);
@@ -283,7 +277,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
foreach (var kvp in Users.OrderByDescending(kvp => kvp.Value))
{
sb.AppendLine(GetText(strs.trivia_points, Format.Bold(kvp.Key.ToString()), kvp.Value).SnPl(kvp.Value));
sb.AppendLine(GetText(strs.trivia_points(Format.Bold(kvp.Key.ToString()), kvp.Value).SnPl(kvp.Value)));
}
return sb.ToString();

View File

@@ -27,7 +27,7 @@ namespace NadekoBot.Modules.Games
[RequireContext(ContextType.Guild)]
public async Task Hangmanlist()
{
await SendConfirmAsync(Format.Code(GetText(strs.hangman_types, Prefix)) + "\n" + string.Join("\n", _service.TermPool.Data.Keys)).ConfigureAwait(false);
await SendConfirmAsync(Format.Code(GetText(strs.hangman_types(Prefix)) + "\n" + string.Join("\n", _service.TermPool.Data.Keys)).ConfigureAwait(false));
}
[NadekoCommand, Aliases]

View File

@@ -43,7 +43,7 @@ namespace NadekoBot.Modules.Games
await ctx.Channel
.EmbedAsync(_eb.Create()
.WithOkColor()
.WithTitle(GetText(strs.poll_created, ctx.User.ToString()))
.WithTitle(GetText(strs.poll_created(ctx.User.ToString())))
.WithDescription(
Format.Bold(poll.Question) + "\n\n" +
string.Join("\n", poll.Answers
@@ -116,7 +116,7 @@ namespace NadekoBot.Modules.Games
}
return eb.WithDescription(sb.ToString())
.WithFooter(GetText(strs.x_votes_cast, totalVotesCast))
.WithFooter(GetText(strs.x_votes_cast(totalVotesCast)))
.WithOkColor();
}
}

View File

@@ -122,7 +122,14 @@ namespace NadekoBot.Modules.Games.Services
{
if (pc.Verbose)
{
var returnMsg = _strings.GetText(strs.perm_prevent, guild.Id, index + 1, Format.Bold(pc.Permissions[index].GetCommand(_cmd.GetPrefix(guild), (SocketGuild)guild))); try { await usrMsg.Channel.SendErrorAsync(_eb, returnMsg).ConfigureAwait(false); } catch { }
var returnMsg = _strings.GetText(
strs.perm_prevent(
guild.Id,
index + 1,
Format.Bold(pc.Permissions[index]
.GetCommand(_cmd.GetPrefix(guild), (SocketGuild)guild))));
try { await usrMsg.Channel.SendErrorAsync(_eb, returnMsg).ConfigureAwait(false); } catch { }
Log.Information(returnMsg);
}
return true;

View File

@@ -99,7 +99,7 @@ namespace NadekoBot.Modules.Help
.OrderBy(module => module.Name)
.ForEach(module => embed.AddField($"{GetModuleEmoji(module.Name)} {module.Name}",
GetText($"module_description_{module.Name.ToLowerInvariant()}") + "\n" +
Format.Code(GetText(strs.module_footer, Prefix, module.Name.ToLowerInvariant())),
Format.Code(GetText(strs.module_footer(Prefix, module.Name.ToLowerInvariant()))),
true));
return embed;
@@ -230,7 +230,7 @@ namespace NadekoBot.Modules.Help
embed.AddField(g.ElementAt(i).Key, "```css\n" + string.Join("\n", transformed) + "\n```", true);
}
}
embed.WithFooter(GetText(strs.commands_instr, Prefix));
embed.WithFooter(GetText(strs.commands_instr(Prefix)));
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
}

View File

@@ -293,10 +293,10 @@ namespace NadekoBot.Modules.Music
var repeatType = mp.Repeat;
var add = "";
if (mp.IsStopped)
add += Format.Bold(GetText(strs.queue_stopped, Format.Code(Prefix + "play"))) + "\n";
add += Format.Bold(GetText(strs.queue_stopped(Format.Code(Prefix + "play")))) + "\n";
// var mps = mp.MaxPlaytimeSeconds;
// if (mps > 0)
// add += Format.Bold(GetText(strs.song_skips_after, TimeSpan.FromSeconds(mps).ToString("HH\\:mm\\:ss"))) + "\n";
// add += Format.Bold(GetText(strs.song_skips_after(TimeSpan.FromSeconds(mps).ToString("HH\\:mm\\:ss")))) + "\n";
if (repeatType == PlayerRepeatType.Track)
{
add += "🔂 " + GetText(strs.repeating_track) + "\n";
@@ -329,7 +329,7 @@ namespace NadekoBot.Modules.Music
desc = add + "\n" + desc;
var embed = _eb.Create()
.WithAuthor(GetText(strs.player_queue, curPage + 1, (tracks.Count / LQ_ITEMS_PER_PAGE) + 1),
.WithAuthor(GetText(strs.player_queue(curPage + 1, (tracks.Count / LQ_ITEMS_PER_PAGE) + 1)),
MusicIconUrl)
.WithDescription(desc)
.WithFooter($" {mp.PrettyVolume()} | 🎶 {tracks.Count} | ⌛ {mp.PrettyTotalTime()} ")

View File

@@ -63,9 +63,9 @@ namespace NadekoBot.Modules.Music
var embed = _eb
.Create(ctx)
.WithAuthor(GetText(strs.playlists_page, num), MusicIconUrl)
.WithAuthor(GetText(strs.playlists_page(num), MusicIconUrl))
.WithDescription(string.Join("\n", playlists.Select(r =>
GetText(strs.playlists, r.Id, r.Name, r.Author, r.Songs.Count))))
GetText(strs.playlists(r.Id, r.Name, r.Author, r.Songs.Count)))))
.WithOkColor();
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
@@ -225,7 +225,7 @@ namespace NadekoBot.Modules.Music
try
{
msg = await ctx.Channel
.SendMessageAsync(GetText(strs.attempting_to_queue, Format.Bold(mpl.Songs.Count.ToString())))
.SendMessageAsync(GetText(strs.attempting_to_queue(Format.Bold(mpl.Songs.Count.ToString()))))
.ConfigureAwait(false);
}
catch (Exception)

View File

@@ -121,7 +121,7 @@ namespace NadekoBot.Modules.Permissions
}
var startPos = 20 * (page - 1);
var toSend = Format.Bold(GetText(strs.page, page)) + "\n\n" + string.Join("\n",
var toSend = Format.Bold(GetText(strs.page(page))) + "\n\n" + string.Join("\n",
perms.Reverse()
.Skip(startPos)
.Take(20)

View File

@@ -83,7 +83,7 @@ namespace NadekoBot.Modules.Searches
var embed = _eb.Create()
.WithOkColor()
.WithTitle(GetText(strs.mal_profile, name))
.WithTitle(GetText(strs.mal_profile(name)))
.AddField("💚 " + GetText(strs.watching), stats[0], true)
.AddField("💙 " + GetText(strs.completed), stats[1], true);
if (info.Count < 3)

View File

@@ -24,7 +24,7 @@ namespace NadekoBot.Modules.Searches
{
var embed = _eb.Create()
.WithTitle(GetText(strs.crypto_not_found))
.WithDescription(GetText(strs.did_you_mean, Format.Bold($"{nearest.Name} ({nearest.Symbol})")));
.WithDescription(GetText(strs.did_you_mean(Format.Bold($"{nearest.Name} ({nearest.Symbol})"))));
if (await PromptUserConfirmAsync(embed).ConfigureAwait(false))
{

View File

@@ -30,7 +30,7 @@ namespace NadekoBot.Modules.Searches
[NadekoCommand, Aliases]
public async Task Placelist()
{
await SendConfirmAsync(GetText(strs.list_of_place_tags, Prefix),
await SendConfirmAsync(GetText(strs.list_of_place_tags(Prefix)),
_typesStr)
.ConfigureAwait(false);
}

View File

@@ -44,7 +44,7 @@ namespace NadekoBot.Modules.Searches
.WithDescription(p.BaseStats.ToString())
.WithThumbnailUrl($"https://assets.pokemon.com/assets/cms2/img/pokedex/detail/{p.Id.ToString("000")}.png")
.AddField(GetText(strs.types), string.Join("\n", p.Types), true)
.AddField(GetText(strs.height_weight), GetText(strs.height_weight_val, p.HeightM, p.WeightKg), true)
.AddField(GetText(strs.height_weight), GetText(strs.height_weight_val(p.HeightM, p.WeightKg), true))
.AddField(GetText(strs.abilities), string.Join("\n", p.Abilities.Select(a => a.Value)), true)).ConfigureAwait(false);
return;
}

View File

@@ -756,7 +756,7 @@ namespace NadekoBot.Modules.Searches
// .AddField(GetText(strs.genres), gameData.TotalEpisodes.ToString(), true)
// .AddField(GetText(strs.price), gameData.IsFree ? GetText(strs.FREE) : game, true)
// .AddField(GetText(strs.links), gameData.GetGenresString(), true)
// .WithFooter(GetText(strs.recommendations, gameData.TotalRecommendations));
// .WithFooter(GetText(strs.recommendations(gameData.TotalRecommendations)));
await ctx.Channel.SendMessageAsync($"https://store.steampowered.com/app/{appId}").ConfigureAwait(false);
}

View File

@@ -55,7 +55,7 @@ namespace NadekoBot.Modules.Utility
"GetHashCode",
"GetType"
});
await SendConfirmAsync(GetText(strs.calcops, Prefix), string.Join(", ", selection)).ConfigureAwait(false);
await SendConfirmAsync(GetText(strs.calcops(Prefix), string.Join(", ", selection)).ConfigureAwait(false));
}
}

View File

@@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Utility
var configNames = _settingServices.Select(x => x.Name);
var embed = _eb.Create()
.WithErrorColor()
.WithDescription(GetText(strs.config_not_found, Format.Code(name)))
.WithDescription(GetText(strs.config_not_found(Format.Code(name))))
.AddField(GetText(strs.config_list), string.Join("\n", configNames));
await ctx.Channel.EmbedAsync(embed);
@@ -90,7 +90,7 @@ namespace NadekoBot.Modules.Utility
{
var embed = _eb.Create()
.WithErrorColor()
.WithDescription(GetText(strs.config_not_found, Format.Code(name)))
.WithDescription(GetText(strs.config_not_found(Format.Code(name))))
.AddField(GetText(strs.config_list), string.Join("\n", configNames));
await ctx.Channel.EmbedAsync(embed);
@@ -123,7 +123,7 @@ namespace NadekoBot.Modules.Utility
var propStrings = GetPropsAndValuesString(setting, propNames);
var propErrorEmbed = _eb.Create()
.WithErrorColor()
.WithDescription(GetText(strs.config_prop_not_found, Format.Code(prop), Format.Code(name)))
.WithDescription(GetText(strs.config_prop_not_found(Format.Code(prop), Format.Code(name))))
.AddField($"⚙️ {setting.Name}", propStrings);
await ctx.Channel.EmbedAsync(propErrorEmbed);

View File

@@ -142,9 +142,9 @@ namespace NadekoBot.Modules.Utility
}
await ctx.Channel.EmbedAsync(_eb.Create()
.WithTitle(GetText(strs.activity_page, page + 1))
.WithTitle(GetText(strs.activity_page(page + 1)))
.WithOkColor()
.WithFooter(GetText(strs.activity_users_total, CmdHandler.UserMessagesSent.Count))
.WithFooter(GetText(strs.activity_users_total(CmdHandler.UserMessagesSent.Count)))
.WithDescription(str.ToString())).ConfigureAwait(false);
}
}

View File

@@ -99,7 +99,7 @@ namespace NadekoBot.Modules.Utility
var inv = invites.ElementAt(index);
await inv.DeleteAsync().ConfigureAwait(false);
await ReplyAsync(GetText(strs.invite_deleted, Format.Bold(inv.Code.ToString()))).ConfigureAwait(false);
await ReplyAsync(GetText(strs.invite_deleted(Format.Bold(inv.Code.ToString()))).ConfigureAwait(false));
}
}
}

View File

@@ -41,8 +41,8 @@ namespace NadekoBot.Modules.Utility
.AddField(GetText(strs.clpa_fail_already_title), GetText(strs.clpa_fail_already))
.AddField(GetText(strs.clpa_fail_wait_title), GetText(strs.clpa_fail_wait))
.AddField(GetText(strs.clpa_fail_conn_title), GetText(strs.clpa_fail_conn))
.AddField(GetText(strs.clpa_fail_sup_title), GetText(strs.clpa_fail_sup, helpcmd))
.WithFooter(GetText(strs.clpa_next_update, rem)));
.AddField(GetText(strs.clpa_fail_sup_title), GetText(strs.clpa_fail_sup(helpcmd)))
.WithFooter(GetText(strs.clpa_next_update(rem))));
}
}
}

View File

@@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Utility
}
if (quotes.Any())
await SendConfirmAsync(GetText(strs.quotes_page, page + 1),
await SendConfirmAsync(GetText(strs.quotes_page(page + 1)),
string.Join("\n", quotes.Select(q => $"`#{q.Id}` {Format.Bold(q.Keyword.SanitizeAllMentions()),-20} by {q.AuthorName.SanitizeAllMentions()}")))
.ConfigureAwait(false);
else
@@ -113,12 +113,12 @@ namespace NadekoBot.Modules.Utility
{
await ctx.Channel.EmbedAsync(_eb.Create(ctx)
.WithOkColor()
.WithTitle(GetText(strs.quote_id, $"#{data.Id}"))
.WithTitle(GetText(strs.quote_id($"#{data.Id}")))
.AddField(GetText(strs.trigger), data.Keyword)
.AddField(GetText(strs.response), data.Text.Length > 1000
? GetText(strs.redacted_too_long)
: Format.Sanitize(data.Text))
.WithFooter(GetText(strs.created_by, $"{data.AuthorName} ({data.AuthorId})"))
.WithFooter(GetText(strs.created_by($"{data.AuthorName} ({data.AuthorId})")))
).ConfigureAwait(false);
}
@@ -222,7 +222,7 @@ namespace NadekoBot.Modules.Utility
uow.Quotes.Remove(q);
await uow.SaveChangesAsync();
success = true;
response = GetText(strs.quote_deleted, id);
response = GetText(strs.quote_deleted(id));
}
}
if (success)

View File

@@ -50,7 +50,7 @@ namespace NadekoBot.Modules.Utility
var description = GetRepeaterInfoString(removed);
await ctx.Channel.EmbedAsync(_eb.Create()
.WithOkColor()
.WithTitle(GetText(strs.repeater_removed, index + 1))
.WithTitle(GetText(strs.repeater_removed(index + 1)))
.WithDescription(description));
}

View File

@@ -89,7 +89,7 @@ namespace NadekoBot.Modules.Utility
}
res = Math.Round(res, 4);
await SendConfirmAsync(GetText(strs.convert, value, originUnit.Triggers.Last(), res, targetUnit.Triggers.Last())).ConfigureAwait(false);
await SendConfirmAsync(GetText(strs.convert(value, originUnit.Triggers.Last(), res, targetUnit.Triggers.Last())).ConfigureAwait(false));
}
}
}

View File

@@ -117,7 +117,7 @@ namespace NadekoBot.Modules.Utility
return _eb.Create().WithOkColor().WithDescription(GetText(strs.no_user_on_this_page));
return _eb.Create().WithOkColor()
.WithTitle(GetText(strs.inrole_list, Format.Bold(role?.Name ?? "No Role")) + $" - {roleUsers.Length}")
.WithTitle(GetText(strs.inrole_list(Format.Bold(role?.Name ?? "No Role")) + $" - {roleUsers.Length}"))
.WithDescription(string.Join("\n", pageUsers));
}, roleUsers.Length, 20).ConfigureAwait(false);
}
@@ -199,7 +199,7 @@ namespace NadekoBot.Modules.Utility
else
{
await SendConfirmAsync(GetText(strs.roles_page, page, Format.Bold(target.ToString())),
await SendConfirmAsync(GetText(strs.roles_page(page, Format.Bold(target.ToString()))),
"\n• " + string.Join("\n• ", (IEnumerable<IRole>)roles).SanitizeMentions(true)).ConfigureAwait(false);
}
}
@@ -212,7 +212,7 @@ namespace NadekoBot.Modules.Utility
}
else
{
await SendConfirmAsync(GetText(strs.roles_all_page, page),
await SendConfirmAsync(GetText(strs.roles_all_page(page)),
"\n• " + string.Join("\n• ", (IEnumerable<IRole>)roles).SanitizeMentions(true)).ConfigureAwait(false);
}
}
@@ -269,7 +269,7 @@ namespace NadekoBot.Modules.Utility
{
var tags = ctx.Message.Tags.Where(t => t.Type == TagType.Emoji).Select(t => (Emote)t.Value);
var result = string.Join("\n", tags.Select(m => GetText(strs.showemojis, m, m.Url)));
var result = string.Join("\n", tags.Select(m => GetText(strs.showemojis(m, m.Url))));
if (string.IsNullOrWhiteSpace(result))
await ReplyErrorLocalizedAsync("showemojis_none").ConfigureAwait(false);
@@ -298,7 +298,7 @@ namespace NadekoBot.Modules.Utility
.WithOkColor();
foreach (var guild in guilds)
embed.AddField(guild.Name,
GetText(strs.listservers, guild.Id, guild.MemberCount, guild.OwnerId),
GetText(strs.listservers(guild.Id, guild.MemberCount, guild.OwnerId)),
false);
await ctx.Channel.EmbedAsync(embed);

View File

@@ -138,7 +138,7 @@ namespace NadekoBot.Modules.Xp
var embed = _eb.Create()
.WithOkColor()
.WithTitle($"{club.ToString()}")
.WithDescription(GetText(strs.level_x, lvl.Level) + $" ({club.Xp} xp)")
.WithDescription(GetText(strs.level_x(lvl.Level) + $" ({club.Xp} xp)"))
.AddField(GetText(strs.desc), string.IsNullOrWhiteSpace(club.Description) ? "-" : club.Description,
false)
.AddField(GetText(strs.owner), club.Owner.ToString(), true)
@@ -188,7 +188,7 @@ namespace NadekoBot.Modules.Xp
.Select(x => x.ToString()));
return _eb.Create()
.WithTitle(GetText(strs.club_bans_for, club.ToString()))
.WithTitle(GetText(strs.club_bans_for(club.ToString())))
.WithDescription(toShow)
.WithOkColor();
}, bans.Length, 10);
@@ -219,7 +219,7 @@ namespace NadekoBot.Modules.Xp
.Select(x => x.ToString()));
return _eb.Create()
.WithTitle(GetText(strs.club_apps_for, club.ToString()))
.WithTitle(GetText(strs.club_apps_for(club.ToString())))
.WithDescription(toShow)
.WithOkColor();
}, apps.Length, 10);
@@ -374,7 +374,7 @@ namespace NadekoBot.Modules.Xp
var clubs = _service.GetClubLeaderboardPage(page);
var embed = _eb.Create()
.WithTitle(GetText(strs.club_leaderboard, page + 1))
.WithTitle(GetText(strs.club_leaderboard(page + 1)))
.WithOkColor();
var i = page * 9;

View File

@@ -72,13 +72,13 @@ namespace NadekoBot.Modules.Xp
var str = ctx.Guild.GetRole(x.RoleId)?.ToString();
if (str is null)
str = GetText(strs.role_not_found, Format.Code(x.RoleId.ToString()));
str = GetText(strs.role_not_found(Format.Code(x.RoleId.ToString())));
else
{
if (!x.Remove)
str = GetText(strs.xp_receive_role, Format.Bold(str));
str = GetText(strs.xp_receive_role(Format.Bold(str)));
else
str = GetText(strs.xp_lose_role, Format.Bold(str));
str = GetText(strs.xp_lose_role(Format.Bold(str)));
}
return (x.Level, Text: sign + str);
})
@@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Xp
foreach (var reward in localRewards)
{
embed.AddField(GetText(strs.level_x, reward.Key),
embed.AddField(GetText(strs.level_x(reward.Key)),
string.Join("\n", reward.Select(y => y.Item2)));
}
@@ -364,7 +364,7 @@ namespace NadekoBot.Modules.Xp
embed.AddField(
$"#{(i + 1 + curPage * 9)} {(user?.ToString() ?? users[i].UserId.ToString())}",
$"{GetText(strs.level_x, levelStats.Level)} - {levelStats.TotalXp}xp {awardStr}");
$"{GetText(strs.level_x(levelStats.Level))} - {levelStats.TotalXp}xp {awardStr}");
}
return embed;
}
@@ -392,7 +392,7 @@ namespace NadekoBot.Modules.Xp
var user = users[i];
embed.AddField(
$"#{i + 1 + page * 9} {(user.ToString())}",
$"{GetText(strs.level_x, new LevelStats(users[i].TotalXp).Level)} - {users[i].TotalXp}xp");
$"{GetText(strs.level_x(new LevelStats(users[i].TotalXp).Level))} - {users[i].TotalXp}xp");
}
}

View File

@@ -377,14 +377,9 @@ namespace NadekoBot.Extensions
return msg.Content.Headers.ContentLength / 1.MB();
}
public static string GetText(this IBotStrings strings, LocStr0 str, ulong? guildId = null)
public static string GetText(this IBotStrings strings, in LocStr str, ulong? guildId = null)
=> strings.GetText(str.Key, guildId);
public static string GetText(this IBotStrings strings, LocStr0 str, CultureInfo culture)
=> strings.GetText(str.Key, culture);
public static string GetText(this IBotStrings strings, LocStr0 str, ulong? guildId = null)
=> strings.GetText(str.Key, guildId);
public static string GetText(this IBotStrings strings, LocStr0 str, CultureInfo culture)
=> strings.GetText(str.Key, culture);
public static string GetText(this IBotStrings strings, in LocStr str, CultureInfo culture)
=> strings.GetText(str.Key, culture, str.Parms);
}
}