mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
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:
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -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]
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user