Second iteration of source generated localized strings

- Strs renamed to strs
- Generic params will now default to object instead of string for convenient argument passing
- Many strings changed to use generated properties
This commit is contained in:
Kwoth
2021-07-24 20:41:07 +02:00
parent 34d0f66466
commit 70288f7670
63 changed files with 410 additions and 363 deletions

View File

@@ -45,7 +45,7 @@ namespace NadekoBot.Modules.Gambling
var ar = new AnimalRace(options, _cs, _gamesConf.Data.RaceAnimals.Shuffle());
if (!_service.AnimalRaces.TryAdd(ctx.Guild.Id, ar))
return SendErrorAsync(GetText("animal_race"), GetText("animal_race_already_started"));
return SendErrorAsync(GetText(strs.animal_race), GetText(strs.animal_race_already_started));
ar.Initialize();
@@ -76,13 +76,13 @@ namespace NadekoBot.Modules.Gambling
var winner = race.FinishedUsers[0];
if (race.FinishedUsers[0].Bet > 0)
{
return SendConfirmAsync(GetText("animal_race"),
return SendConfirmAsync(GetText(strs.animal_race),
GetText("animal_race_won_money", Format.Bold(winner.Username),
winner.Animal.Icon, (race.FinishedUsers[0].Bet * (race.Users.Count - 1)) + CurrencySign));
}
else
{
return SendConfirmAsync(GetText("animal_race"),
return SendConfirmAsync(GetText(strs.animal_race),
GetText("animal_race_won", Format.Bold(winner.Username), winner.Animal.Icon));
}
}
@@ -93,16 +93,16 @@ namespace NadekoBot.Modules.Gambling
ar.OnStarted += Ar_OnStarted;
_client.MessageReceived += _client_MessageReceived;
return SendConfirmAsync(GetText("animal_race"), GetText("animal_race_starting", options.StartTime),
return SendConfirmAsync(GetText(strs.animal_race), GetText("animal_race_starting", options.StartTime),
footer: GetText("animal_race_join_instr", Prefix));
}
private Task Ar_OnStarted(AnimalRace race)
{
if (race.Users.Count == race.MaxUsers)
return SendConfirmAsync(GetText("animal_race"), GetText("animal_race_full"));
return SendConfirmAsync(GetText(strs.animal_race), GetText(strs.animal_race_full));
else
return SendConfirmAsync(GetText("animal_race"), GetText("animal_race_starting_with_x", race.Users.Count));
return SendConfirmAsync(GetText(strs.animal_race), GetText("animal_race_starting_with_x", race.Users.Count));
}
private async Task Ar_OnStateUpdate(AnimalRace race)
@@ -123,7 +123,7 @@ namespace NadekoBot.Modules.Gambling
.ConfigureAwait(false);
else
await msg.ModifyAsync(x => x.Embed = _eb.Create()
.WithTitle(GetText("animal_race"))
.WithTitle(GetText(strs.animal_race))
.WithDescription(text)
.WithOkColor()
.Build())
@@ -171,7 +171,7 @@ namespace NadekoBot.Modules.Gambling
}
catch (AnimalRaceFullException)
{
await SendConfirmAsync(GetText("animal_race"), GetText("animal_race_full"))
await SendConfirmAsync(GetText(strs.animal_race), GetText(strs.animal_race_full))
.ConfigureAwait(false);
}
catch (NotEnoughFundsException)

View File

@@ -136,7 +136,7 @@ namespace NadekoBot.Modules.Gambling
title = GetText("connect4_won", Format.Bold(arg.OtherPlayer.Username), Format.Bold(arg.CurrentPlayer.Username));
}
else
title = GetText("connect4_draw");
title = GetText(strs.connect4_draw);
return msg.ModifyAsync(x => x.Embed = _eb.Create()
.WithTitle(title)

View File

@@ -69,8 +69,8 @@ namespace NadekoBot.Modules.Gambling
var msg = count != 1
? Format.Bold(ctx.User.ToString()) + " " + GetText("flip_results", count, headCount, tailCount)
: Format.Bold(ctx.User.ToString()) + " " + GetText("flipped", headCount > 0
? Format.Bold(GetText("heads"))
: Format.Bold(GetText("tails")));
? Format.Bold(GetText(strs.heads))
: Format.Bold(GetText(strs.tails)));
await ctx.Channel.SendFileAsync(stream, $"{count} coins.{format.FileExtensions.First()}", msg).ConfigureAwait(false);
}
}
@@ -120,7 +120,7 @@ namespace NadekoBot.Modules.Gambling
}
else
{
str = ctx.User.ToString() + " " + GetText("better_luck");
str = ctx.User.ToString() + " " + GetText(strs.better_luck);
}
await ctx.Channel.EmbedAsync(_eb.Create()

View File

@@ -65,13 +65,13 @@ namespace NadekoBot.Modules.Gambling
// [21:03] Bob Page: Kinda remids me of US economy
}
var embed = _eb.Create()
.WithTitle(GetText("economy_state"))
.AddField(GetText("currency_owned"), ((BigInteger)(ec.Cash - ec.Bot)) + CurrencySign)
.AddField(GetText("currency_one_percent"), (onePercent * 100).ToString("F2") + "%")
.AddField(GetText("currency_planted"), ((BigInteger)ec.Planted) + CurrencySign)
.AddField(GetText("owned_waifus_total"), ((BigInteger)ec.Waifus) + CurrencySign)
.AddField(GetText("bot_currency"), ec.Bot + CurrencySign)
.AddField(GetText("total"), ((BigInteger)(ec.Cash + ec.Planted + ec.Waifus)).ToString("N", _enUsCulture) + CurrencySign)
.WithTitle(GetText(strs.economy_state))
.AddField(GetText(strs.currency_owned), ((BigInteger)(ec.Cash - ec.Bot)) + CurrencySign)
.AddField(GetText(strs.currency_one_percent), (onePercent * 100).ToString("F2") + "%")
.AddField(GetText(strs.currency_planted), ((BigInteger)ec.Planted) + CurrencySign)
.AddField(GetText(strs.owned_waifus_total), ((BigInteger)ec.Waifus) + CurrencySign)
.AddField(GetText(strs.bot_currency), ec.Bot + CurrencySign)
.AddField(GetText(strs.total), ((BigInteger)(ec.Cash + ec.Planted + ec.Waifus)).ToString("N", _enUsCulture) + CurrencySign)
.WithOkColor();
// ec.Cash already contains ec.Bot as it's the total of all values in the CurrencyAmount column of the DiscordUser table
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
@@ -140,7 +140,7 @@ namespace NadekoBot.Modules.Gambling
return;
}
var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)];
await SendConfirmAsync("🎟 " + GetText("raffled_user"), $"**{usr.Username}#{usr.Discriminator}**", footer: $"ID: {usr.Id}").ConfigureAwait(false);
await SendConfirmAsync("🎟 " + GetText(strs.raffled_user), $"**{usr.Username}#{usr.Discriminator}**", footer: $"ID: {usr.Id}").ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -156,7 +156,7 @@ namespace NadekoBot.Modules.Gambling
return;
}
var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)];
await SendConfirmAsync("🎟 " + GetText("raffled_user"), $"**{usr.Username}#{usr.Discriminator}**", footer: $"ID: {usr.Id}").ConfigureAwait(false);
await SendConfirmAsync("🎟 " + GetText(strs.raffled_user), $"**{usr.Username}#{usr.Discriminator}**", footer: $"ID: {usr.Id}").ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -375,7 +375,7 @@ namespace NadekoBot.Modules.Gambling
var embed = _eb.Create()
.WithOkColor()
.WithTitle(GetText("roll_duel"));
.WithTitle(GetText(strs.roll_duel));
var description = string.Empty;
@@ -488,7 +488,7 @@ namespace NadekoBot.Modules.Gambling
}
else
{
str += GetText("better_luck");
str += GetText(strs.better_luck);
}
await SendConfirmAsync(str).ConfigureAwait(false);
@@ -549,7 +549,7 @@ namespace NadekoBot.Modules.Gambling
{
var embed = _eb.Create()
.WithOkColor()
.WithTitle(CurrencySign + " " + GetText("leaderboard"));
.WithTitle(CurrencySign + " " + GetText(strs.leaderboard));
List<DiscordUser> toSend;
if (!opts.Clean)
@@ -565,7 +565,7 @@ namespace NadekoBot.Modules.Gambling
}
if (!toSend.Any())
{
embed.WithDescription(GetText("no_user_on_this_page"));
embed.WithDescription(GetText(strs.no_user_on_this_page));
return embed;
}
@@ -651,7 +651,7 @@ namespace NadekoBot.Modules.Gambling
await _cs.AddAsync(ctx.User.Id,
"Rps-win", amount, gamble: true).ConfigureAwait(false);
embed.WithOkColor();
embed.AddField(GetText("won"), n(amount));
embed.AddField(GetText(strs.won), n(amount));
msg = GetText("rps_win", ctx.User.Mention,
getRpsPick(pick), getRpsPick(nadekoPick));
}

View File

@@ -60,7 +60,7 @@ namespace NadekoBot.Modules.Gambling
if (!theseEntries.Any())
return _eb.Create().WithErrorColor()
.WithDescription(GetText("shop_none"));
.WithDescription(GetText(strs.shop_none));
var embed = _eb.Create().WithOkColor()
.WithTitle(GetText("shop", CurrencySign));
@@ -174,9 +174,9 @@ namespace NadekoBot.Modules.Gambling
await (await ctx.User.GetOrCreateDMChannelAsync().ConfigureAwait(false))
.EmbedAsync(_eb.Create().WithOkColor()
.WithTitle(GetText("shop_purchase", ctx.Guild.Name))
.AddField(GetText("item"), item.Text, false)
.AddField(GetText("price"), entry.Price.ToString(), true)
.AddField(GetText("name"), entry.Name, true))
.AddField(GetText(strs.item), item.Text, false)
.AddField(GetText(strs.price), entry.Price.ToString(), true)
.AddField(GetText(strs.name), entry.Name, true))
.ConfigureAwait(false);
await _cs.AddAsync(entry.AuthorId,
@@ -246,7 +246,7 @@ namespace NadekoBot.Modules.Gambling
uow.SaveChanges();
}
await ctx.Channel.EmbedAsync(EntryToEmbed(entry)
.WithTitle(GetText("shop_item_add"))).ConfigureAwait(false);
.WithTitle(GetText(strs.shop_item_add))).ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -274,7 +274,7 @@ namespace NadekoBot.Modules.Gambling
uow.SaveChanges();
}
await ctx.Channel.EmbedAsync(EntryToEmbed(entry)
.WithTitle(GetText("shop_item_add"))).ConfigureAwait(false);
.WithTitle(GetText(strs.shop_item_add))).ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -345,7 +345,7 @@ namespace NadekoBot.Modules.Gambling
await ReplyErrorLocalizedAsync("shop_item_not_found").ConfigureAwait(false);
else
await ctx.Channel.EmbedAsync(EntryToEmbed(removed)
.WithTitle(GetText("shop_item_rm"))).ConfigureAwait(false);
.WithTitle(GetText(strs.shop_item_rm))).ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -433,17 +433,17 @@ namespace NadekoBot.Modules.Gambling
var embed = _eb.Create().WithOkColor();
if (entry.Type == ShopEntryType.Role)
return embed.AddField(GetText("name"), GetText("shop_role", Format.Bold(ctx.Guild.GetRole(entry.RoleId)?.Name ?? "MISSING_ROLE")), true)
.AddField(GetText("price"), entry.Price.ToString(), true)
.AddField(GetText("type"), entry.Type.ToString(), true);
return embed.AddField(GetText(strs.name), GetText("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)
return embed.AddField(GetText("name"), entry.Name, true)
.AddField(GetText("price"), entry.Price.ToString(), true)
.AddField(GetText("type"), GetText("random_unique_item"), true);
return embed.AddField(GetText(strs.name), entry.Name, true)
.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("name"), GetText("shop_role", Format.Bold(entry.RoleName)), true)
// .AddField(GetText("price"), entry.Price.ToString(), true)
// .AddField(GetText("type"), entry.Type.ToString(), true);
// return embed.AddField(GetText(strs.name), GetText("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;
}

View File

@@ -197,7 +197,7 @@ namespace NadekoBot.Modules.Gambling
n++;
} while ((printAmount /= 10) != 0);
var msg = GetText("better_luck");
var msg = GetText(strs.better_luck);
if (result.Multiplier != 0)
{
await _cs.AddAsync(ctx.User, $"Slot Machine x{result.Multiplier}", amount * result.Multiplier, false, gamble: true).ConfigureAwait(false);
@@ -214,7 +214,7 @@ namespace NadekoBot.Modules.Gambling
using (var imgStream = bgImage.ToStream())
{
await ctx.Channel.SendFileAsync(imgStream, "result.png", ctx.User.Mention + " " + msg + $"\n`{GetText("slot_bet")}:`{amount} `{GetText("won")}:` {amount * result.Multiplier}{CurrencySign}").ConfigureAwait(false);
await ctx.Channel.SendFileAsync(imgStream, "result.png", ctx.User.Mention + " " + msg + $"\n`{GetText(strs.slot_bet)}:`{amount} `{GetText(strs.won)}:` {amount * result.Multiplier}{CurrencySign}").ConfigureAwait(false);
}
}
}

View File

@@ -26,7 +26,7 @@ namespace NadekoBot.Modules.Gambling
{
var price = _service.GetResetPrice(ctx.User);
var embed = _eb.Create()
.WithTitle(GetText("waifu_reset_confirm"))
.WithTitle(GetText(strs.waifu_reset_confirm))
.WithDescription(GetText("waifu_reset_price", Format.Bold(price + CurrencySign)));
if (!await PromptUserConfirmAsync(embed))
@@ -222,7 +222,7 @@ namespace NadekoBot.Modules.Gambling
}
var embed = _eb.Create()
.WithTitle(GetText("waifus_top_waifus"))
.WithTitle(GetText(strs.waifus_top_waifus))
.WithOkColor();
var i = 0;
@@ -261,7 +261,7 @@ namespace NadekoBot.Modules.Gambling
.ToDictionary(x => x.ItemEmoji, x => x);
var nobody = GetText("nobody");
var nobody = GetText(strs.nobody);
var itemsStr = !wi.Items.Any()
? "-"
: string.Join("\n", wi.Items
@@ -284,19 +284,19 @@ namespace NadekoBot.Modules.Gambling
var embed = _eb.Create()
.WithOkColor()
.WithTitle(GetText("waifu") + " " + (wi.FullName ?? name ?? targetId.ToString()) + " - \"the " +
.WithTitle(GetText(strs.waifu) + " " + (wi.FullName ?? name ?? targetId.ToString()) + " - \"the " +
_service.GetClaimTitle(wi.ClaimCount) + "\"")
.AddField(GetText("price"), wi.Price.ToString(), true)
.AddField(GetText("claimed_by"), wi.ClaimerName ?? nobody, true)
.AddField(GetText("likes"), wi.AffinityName ?? nobody, true)
.AddField(GetText("changes_of_heart"), $"{wi.AffinityCount} - \"the {affInfo}\"", true)
.AddField(GetText("divorces"), wi.DivorceCount.ToString(), true)
.AddField(GetText(strs.price), wi.Price.ToString(), true)
.AddField(GetText(strs.claimed_by), wi.ClaimerName ?? nobody, true)
.AddField(GetText(strs.likes), wi.AffinityName ?? nobody, true)
.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("fans", wi.Fans.Count), fansStr, true)
.AddField($"Waifus ({wi.ClaimCount})", wi.ClaimCount == 0
? nobody
: string.Join("\n", wi.Claims.Shuffle().Take(30)), true)
.AddField(GetText("gifts"), itemsStr, true);
.AddField(GetText(strs.gifts), itemsStr, true);
return ctx.Channel.EmbedAsync(embed);
}
@@ -313,7 +313,7 @@ namespace NadekoBot.Modules.Gambling
await ctx.SendPaginatedConfirmAsync(page, (cur) =>
{
var embed = _eb.Create()
.WithTitle(GetText("waifu_gift_shop"))
.WithTitle(GetText(strs.waifu_gift_shop))
.WithOkColor();
waifuItems