mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
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:
@@ -81,7 +81,7 @@ namespace NadekoBot.Modules.Games
|
||||
private Task Game_OnStarted(AcrophobiaGame game)
|
||||
{
|
||||
var embed = _eb.Create().WithOkColor()
|
||||
.WithTitle(GetText("acrophobia"))
|
||||
.WithTitle(GetText(strs.acrophobia))
|
||||
.WithDescription(GetText("acro_started", Format.Bold(string.Join(".", game.StartingLetters))))
|
||||
.WithFooter(GetText("acro_started_footer", game.Opts.SubmissionTime));
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace NadekoBot.Modules.Games
|
||||
private Task Game_OnUserVoted(string user)
|
||||
{
|
||||
return SendConfirmAsync(
|
||||
GetText("acrophobia"),
|
||||
GetText(strs.acrophobia),
|
||||
GetText("acro_vote_cast", Format.Bold(user)));
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace NadekoBot.Modules.Games
|
||||
{
|
||||
if (submissions.Length == 0)
|
||||
{
|
||||
await SendErrorAsync(GetText("acrophobia"), GetText("acro_ended_no_sub")).ConfigureAwait(false);
|
||||
await SendErrorAsync(GetText(strs.acrophobia), GetText(strs.acro_ended_no_sub)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
if (submissions.Length == 1)
|
||||
@@ -117,12 +117,12 @@ namespace NadekoBot.Modules.Games
|
||||
var i = 0;
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText("acrophobia") + " - " + GetText("submissions_closed"))
|
||||
.WithTitle(GetText(strs.acrophobia) + " - " + GetText(strs.submissions_closed))
|
||||
.WithDescription(GetText("acro_nym_was", Format.Bold(string.Join(".", game.StartingLetters)) + "\n" +
|
||||
$@"--
|
||||
{submissions.Aggregate("", (agg, cur) => agg + $"`{++i}.` **{cur.Key.Input}**\n")}
|
||||
--"))
|
||||
.WithFooter(GetText("acro_vote"));
|
||||
.WithFooter(GetText(strs.acro_vote));
|
||||
|
||||
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
}
|
||||
@@ -131,13 +131,13 @@ $@"--
|
||||
{
|
||||
if (!votes.Any() || votes.All(x => x.Value == 0))
|
||||
{
|
||||
await SendErrorAsync(GetText("acrophobia"), GetText("acro_no_votes_cast")).ConfigureAwait(false);
|
||||
await SendErrorAsync(GetText(strs.acrophobia), GetText(strs.acro_no_votes_cast)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var table = votes.OrderByDescending(v => v.Value);
|
||||
var winner = table.First();
|
||||
var embed = _eb.Create().WithOkColor()
|
||||
.WithTitle(GetText("acrophobia"))
|
||||
.WithTitle(GetText(strs.acrophobia))
|
||||
.WithDescription(GetText("acro_winner", Format.Bold(winner.Key.UserName),
|
||||
Format.Bold(winner.Value.ToString())))
|
||||
.WithFooter(winner.Key.Input);
|
||||
|
@@ -72,8 +72,14 @@ namespace NadekoBot.Modules.Games.Common
|
||||
_moveLock = new SemaphoreSlim(1, 1);
|
||||
}
|
||||
|
||||
private string GetText(string key, params object[] replacements)
|
||||
=> _strings.GetText(key, _channel.GuildId, replacements);
|
||||
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()
|
||||
{
|
||||
@@ -98,7 +104,7 @@ namespace NadekoBot.Modules.Games.Common
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithDescription(Environment.NewLine + GetState())
|
||||
.WithAuthor(GetText("vs", _users[0], _users[1]));
|
||||
.WithAuthor(GetText(strs.vs, _users[0], _users[1]));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(title))
|
||||
embed.WithTitle(title);
|
||||
@@ -106,7 +112,7 @@ namespace NadekoBot.Modules.Games.Common
|
||||
if (_winner is null)
|
||||
{
|
||||
if (_phase == Phase.Ended)
|
||||
embed.WithFooter(GetText("ttt_no_moves"));
|
||||
embed.WithFooter(GetText(strs.ttt_no_moves));
|
||||
else
|
||||
embed.WithFooter(GetText("ttt_users_move", _users[_curUserIndex]));
|
||||
}
|
||||
@@ -137,12 +143,12 @@ namespace NadekoBot.Modules.Games.Common
|
||||
{
|
||||
if (_phase == Phase.Started || _phase == Phase.Ended)
|
||||
{
|
||||
await _channel.SendErrorAsync(_eb, user.Mention + GetText("ttt_already_running")).ConfigureAwait(false);
|
||||
await _channel.SendErrorAsync(_eb, user.Mention + GetText(strs.ttt_already_running)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
else if (_users[0] == user)
|
||||
{
|
||||
await _channel.SendErrorAsync(_eb, user.Mention + GetText("ttt_against_yourself")).ConfigureAwait(false);
|
||||
await _channel.SendErrorAsync(_eb, user.Mention + GetText(strs.ttt_against_yourself)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -165,7 +171,7 @@ namespace NadekoBot.Modules.Games.Common
|
||||
var del = _previousMessage?.DeleteAsync();
|
||||
try
|
||||
{
|
||||
await _channel.EmbedAsync(GetEmbed(GetText("ttt_time_expired"))).ConfigureAwait(false);
|
||||
await _channel.EmbedAsync(GetEmbed(GetText(strs.ttt_time_expired))).ConfigureAwait(false);
|
||||
if (del != null)
|
||||
await del.ConfigureAwait(false);
|
||||
}
|
||||
@@ -184,7 +190,7 @@ namespace NadekoBot.Modules.Games.Common
|
||||
_client.MessageReceived += Client_MessageReceived;
|
||||
|
||||
|
||||
_previousMessage = await _channel.EmbedAsync(GetEmbed(GetText("game_started"))).ConfigureAwait(false);
|
||||
_previousMessage = await _channel.EmbedAsync(GetEmbed(GetText(strs.game_started))).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private bool IsDraw()
|
||||
@@ -255,14 +261,14 @@ namespace NadekoBot.Modules.Games.Common
|
||||
|
||||
if (_phase == Phase.Ended) // if user won, stop receiving moves
|
||||
{
|
||||
reason = GetText("ttt_matched_three");
|
||||
reason = GetText(strs.ttt_matched_three);
|
||||
_winner = _users[_curUserIndex];
|
||||
_client.MessageReceived -= Client_MessageReceived;
|
||||
OnEnded?.Invoke(this);
|
||||
}
|
||||
else if (IsDraw())
|
||||
{
|
||||
reason = GetText("ttt_a_draw");
|
||||
reason = GetText(strs.ttt_a_draw);
|
||||
_phase = Phase.Ended;
|
||||
_client.MessageReceived -= Client_MessageReceived;
|
||||
OnEnded?.Invoke(this);
|
||||
|
@@ -62,8 +62,14 @@ namespace NadekoBot.Modules.Games.Common.Trivia
|
||||
Channel = channel;
|
||||
}
|
||||
|
||||
private string GetText(string key, params object[] replacements)
|
||||
=> _strings.GetText(key, Channel.GuildId, replacements);
|
||||
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()
|
||||
{
|
||||
@@ -78,7 +84,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
|
||||
CurrentQuestion = _questionPool.GetRandomQuestion(OldQuestions, _options.IsPokemon);
|
||||
if (string.IsNullOrWhiteSpace(CurrentQuestion?.Answer) || string.IsNullOrWhiteSpace(CurrentQuestion.Question))
|
||||
{
|
||||
await Channel.SendErrorAsync(_eb, GetText("trivia_game"), GetText("failed_loading_question")).ConfigureAwait(false);
|
||||
await Channel.SendErrorAsync(_eb, GetText(strs.trivia_game), GetText(strs.failed_loading_question)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
OldQuestions.Add(CurrentQuestion); //add it to exclusion list so it doesn't show up again
|
||||
@@ -88,12 +94,12 @@ namespace NadekoBot.Modules.Games.Common.Trivia
|
||||
try
|
||||
{
|
||||
questionEmbed = _eb.Create().WithOkColor()
|
||||
.WithTitle(GetText("trivia_game"))
|
||||
.AddField(GetText("category"), CurrentQuestion.Category)
|
||||
.AddField(GetText("question"), CurrentQuestion.Question);
|
||||
.WithTitle(GetText(strs.trivia_game))
|
||||
.AddField(GetText(strs.category), CurrentQuestion.Category)
|
||||
.AddField(GetText(strs.question), CurrentQuestion.Question);
|
||||
|
||||
if (showHowToQuit)
|
||||
questionEmbed.WithFooter(GetText("trivia_quit", _quitCommand));
|
||||
questionEmbed.WithFooter(GetText(strs.trivia_quit, _quitCommand));
|
||||
|
||||
if (Uri.IsWellFormedUriString(CurrentQuestion.ImageUrl, UriKind.Absolute))
|
||||
questionEmbed.WithImageUrl(CurrentQuestion.ImageUrl);
|
||||
@@ -152,8 +158,8 @@ namespace NadekoBot.Modules.Games.Common.Trivia
|
||||
try
|
||||
{
|
||||
var embed = _eb.Create().WithErrorColor()
|
||||
.WithTitle(GetText("trivia_game"))
|
||||
.WithDescription(GetText("trivia_times_up", Format.Bold(CurrentQuestion.Answer)));
|
||||
.WithTitle(GetText(strs.trivia_game))
|
||||
.WithDescription(GetText(strs.trivia_times_up, Format.Bold(CurrentQuestion.Answer)));
|
||||
if (Uri.IsWellFormedUriString(CurrentQuestion.AnswerImageUrl, UriKind.Absolute))
|
||||
embed.WithImageUrl(CurrentQuestion.AnswerImageUrl);
|
||||
|
||||
@@ -190,8 +196,8 @@ namespace NadekoBot.Modules.Games.Common.Trivia
|
||||
try
|
||||
{
|
||||
await Channel.SendConfirmAsync(_eb,
|
||||
GetText("trivia_game"),
|
||||
GetText("trivia_stopping"));
|
||||
GetText(strs.trivia_game),
|
||||
GetText(strs.trivia_stopping));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -239,7 +245,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
|
||||
try
|
||||
{
|
||||
var embedS = _eb.Create().WithOkColor()
|
||||
.WithTitle(GetText("trivia_game"))
|
||||
.WithTitle(GetText(strs.trivia_game))
|
||||
.WithDescription(GetText("trivia_win",
|
||||
guildUser.Mention,
|
||||
Format.Bold(CurrentQuestion.Answer)));
|
||||
@@ -257,7 +263,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
|
||||
return;
|
||||
}
|
||||
var embed = _eb.Create().WithOkColor()
|
||||
.WithTitle(GetText("trivia_game"))
|
||||
.WithTitle(GetText(strs.trivia_game))
|
||||
.WithDescription(GetText("trivia_guess", guildUser.Mention, Format.Bold(CurrentQuestion.Answer)));
|
||||
if (Uri.IsWellFormedUriString(CurrentQuestion.AnswerImageUrl, UriKind.Absolute))
|
||||
embed.WithImageUrl(CurrentQuestion.AnswerImageUrl);
|
||||
@@ -271,7 +277,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
|
||||
public string GetLeaderboard()
|
||||
{
|
||||
if (Users.Count == 0)
|
||||
return GetText("no_results");
|
||||
return GetText(strs.no_results);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
|
@@ -50,8 +50,8 @@ namespace NadekoBot.Modules.Games
|
||||
var res = _service.GetEightballResponse(ctx.User.Id, question);
|
||||
await ctx.Channel.EmbedAsync(_eb.Create().WithOkColor()
|
||||
.WithDescription(ctx.User.ToString())
|
||||
.AddField("❓ " + GetText("question"), question, false)
|
||||
.AddField("🎱 " + GetText("_8ball"), res, false));
|
||||
.AddField("❓ " + GetText(strs.question), question, false)
|
||||
.AddField("🎱 " + GetText(strs._8ball), res, false));
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
|
@@ -58,7 +58,7 @@ namespace NadekoBot.Modules.Games
|
||||
|
||||
try
|
||||
{
|
||||
await SendConfirmAsync(GetText("hangman_game_started") + $" ({hm.TermType})",
|
||||
await SendConfirmAsync(GetText(strs.hangman_game_started) + $" ({hm.TermType})",
|
||||
hm.ScrambledWord + "\n" + hm.GetHangman())
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@ namespace NadekoBot.Modules.Games
|
||||
if (!_service.ActivePolls.TryGetValue(ctx.Guild.Id, out var pr))
|
||||
return;
|
||||
|
||||
await ctx.Channel.EmbedAsync(GetStats(pr.Poll, GetText("current_poll_results"))).ConfigureAwait(false);
|
||||
await ctx.Channel.EmbedAsync(GetStats(pr.Poll, GetText(strs.current_poll_results))).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
@@ -78,7 +78,7 @@ namespace NadekoBot.Modules.Games
|
||||
if ((p = _service.StopPoll(ctx.Guild.Id)) is null)
|
||||
return;
|
||||
|
||||
var embed = GetStats(p, GetText("poll_closed"));
|
||||
var embed = GetStats(p, GetText(strs.poll_closed));
|
||||
await ctx.Channel.EmbedAsync(embed)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ namespace NadekoBot.Modules.Games
|
||||
return;
|
||||
}
|
||||
|
||||
await SendErrorAsync(GetText("trivia_already_running") + "\n" + trivia.CurrentQuestion)
|
||||
await SendErrorAsync(GetText(strs.trivia_already_running) + "\n" + trivia.CurrentQuestion)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace NadekoBot.Modules.Games
|
||||
{
|
||||
if (_service.RunningTrivias.TryGetValue(ctx.Guild.Id, out TriviaGame trivia))
|
||||
{
|
||||
await SendConfirmAsync(GetText("leaderboard"), trivia.GetLeaderboard()).ConfigureAwait(false);
|
||||
await SendConfirmAsync(GetText(strs.leaderboard), trivia.GetLeaderboard()).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user