Rename Fluent-related code to be more precise.

This commit is contained in:
Paul Chote
2024-10-01 19:34:12 +01:00
committed by Gustas
parent 771b9ddfda
commit b29b685058
176 changed files with 1349 additions and 1369 deletions

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Server
{
sealed class PlayerMessageTracker
{
[TranslationReference("remaining")]
[FluentReference("remaining")]
const string ChatTemporaryDisabled = "notification-chat-temp-disabled";
readonly Dictionary<int, List<long>> messageTracker = new();
@@ -56,7 +56,7 @@ namespace OpenRA.Server
if (!isAdmin && time < settings.FloodLimitJoinCooldown)
{
var remaining = CalculateRemaining(settings.FloodLimitJoinCooldown);
sendLocalizedMessageTo(conn, ChatTemporaryDisabled, Translation.Arguments("remaining", remaining));
sendLocalizedMessageTo(conn, ChatTemporaryDisabled, FluentBundle.Arguments("remaining", remaining));
return true;
}
@@ -64,7 +64,7 @@ namespace OpenRA.Server
if (tracker.Count >= settings.FloodLimitMessageCount)
{
var remaining = CalculateRemaining(tracker[0] + settings.FloodLimitInterval);
sendLocalizedMessageTo(conn, ChatTemporaryDisabled, Translation.Arguments("remaining", remaining));
sendLocalizedMessageTo(conn, ChatTemporaryDisabled, FluentBundle.Arguments("remaining", remaining));
return true;
}

View File

@@ -47,73 +47,73 @@ namespace OpenRA.Server
public sealed class Server
{
[TranslationReference]
[FluentReference]
const string CustomRules = "notification-custom-rules";
[TranslationReference]
[FluentReference]
const string BotsDisabled = "notification-map-bots-disabled";
[TranslationReference]
[FluentReference]
const string TwoHumansRequired = "notification-two-humans-required";
[TranslationReference]
[FluentReference]
const string ErrorGameStarted = "notification-error-game-started";
[TranslationReference]
[FluentReference]
const string RequiresPassword = "notification-requires-password";
[TranslationReference]
[FluentReference]
const string IncorrectPassword = "notification-incorrect-password";
[TranslationReference]
[FluentReference]
const string IncompatibleMod = "notification-incompatible-mod";
[TranslationReference]
[FluentReference]
const string IncompatibleVersion = "notification-incompatible-version";
[TranslationReference]
[FluentReference]
const string IncompatibleProtocol = "notification-incompatible-protocol";
[TranslationReference]
[FluentReference]
const string Banned = "notification-you-were-banned";
[TranslationReference]
[FluentReference]
const string TempBanned = "notification-you-were-temp-banned";
[TranslationReference]
[FluentReference]
const string Full = "notification-game-full";
[TranslationReference("player")]
[FluentReference("player")]
const string Joined = "notification-joined";
[TranslationReference]
[FluentReference]
const string RequiresAuthentication = "notification-requires-authentication";
[TranslationReference]
[FluentReference]
const string NoPermission = "notification-no-permission-to-join";
[TranslationReference("command")]
[FluentReference("command")]
const string UnknownServerCommand = "notification-unknown-server-command";
[TranslationReference("player")]
[FluentReference("player")]
const string LobbyDisconnected = "notification-lobby-disconnected";
[TranslationReference("player")]
[FluentReference("player")]
const string PlayerDisconnected = "notification-player-disconnected";
[TranslationReference("player", "team")]
[FluentReference("player", "team")]
const string PlayerTeamDisconnected = "notification-team-player-disconnected";
[TranslationReference("player")]
[FluentReference("player")]
const string ObserverDisconnected = "notification-observer-disconnected";
[TranslationReference("player")]
[FluentReference("player")]
const string NewAdmin = "notification-new-admin";
[TranslationReference]
[FluentReference]
const string YouWereKicked = "notification-you-were-kicked";
[TranslationReference]
[FluentReference]
const string GameStarted = "notification-game-started";
public readonly MersenneTwister Random = new();
@@ -580,7 +580,7 @@ namespace OpenRA.Server
Log.Write("server", $"{client.Name} ({newConn.EndPoint}) has joined the game.");
SendLocalizedMessage(Joined, Translation.Arguments("player", client.Name));
SendLocalizedMessage(Joined, FluentBundle.Arguments("player", client.Name));
if (Type == ServerType.Dedicated)
{
@@ -954,17 +954,17 @@ namespace OpenRA.Server
public void SendLocalizedMessage(string key, Dictionary<string, object> arguments = null)
{
var text = LocalizedMessage.Serialize(key, arguments);
DispatchServerOrdersToClients(Order.FromTargetString("LocalizedMessage", text, true));
var text = FluentMessage.Serialize(key, arguments);
DispatchServerOrdersToClients(Order.FromTargetString("FluentMessage", text, true));
if (Type == ServerType.Dedicated)
WriteLineWithTimeStamp(TranslationProvider.GetString(key, arguments));
WriteLineWithTimeStamp(FluentProvider.GetString(key, arguments));
}
public void SendLocalizedMessageTo(Connection conn, string key, Dictionary<string, object> arguments = null)
{
var text = LocalizedMessage.Serialize(key, arguments);
DispatchOrdersToClient(conn, 0, 0, Order.FromTargetString("LocalizedMessage", text, true).Serialize());
var text = FluentMessage.Serialize(key, arguments);
DispatchOrdersToClient(conn, 0, 0, Order.FromTargetString("FluentMessage", text, true).Serialize());
}
void WriteLineWithTimeStamp(string line)
@@ -998,7 +998,7 @@ namespace OpenRA.Server
if (!InterpretCommand(o.TargetString, conn))
{
Log.Write("server", $"Unknown server command: {o.TargetString}");
SendLocalizedMessageTo(conn, UnknownServerCommand, Translation.Arguments("command", o.TargetString));
SendLocalizedMessageTo(conn, UnknownServerCommand, FluentBundle.Arguments("command", o.TargetString));
}
break;
@@ -1180,14 +1180,14 @@ namespace OpenRA.Server
if (State == ServerState.GameStarted)
{
if (dropClient.IsObserver)
SendLocalizedMessage(ObserverDisconnected, Translation.Arguments("player", dropClient.Name));
SendLocalizedMessage(ObserverDisconnected, FluentBundle.Arguments("player", dropClient.Name));
else if (dropClient.Team > 0)
SendLocalizedMessage(PlayerTeamDisconnected, Translation.Arguments("player", dropClient.Name, "team", dropClient.Team));
SendLocalizedMessage(PlayerTeamDisconnected, FluentBundle.Arguments("player", dropClient.Name, "team", dropClient.Team));
else
SendLocalizedMessage(PlayerDisconnected, Translation.Arguments("player", dropClient.Name));
SendLocalizedMessage(PlayerDisconnected, FluentBundle.Arguments("player", dropClient.Name));
}
else
SendLocalizedMessage(LobbyDisconnected, Translation.Arguments("player", dropClient.Name));
SendLocalizedMessage(LobbyDisconnected, FluentBundle.Arguments("player", dropClient.Name));
LobbyInfo.Clients.RemoveAll(c => c.Index == toDrop.PlayerIndex);
@@ -1204,7 +1204,7 @@ namespace OpenRA.Server
if (nextAdmin != null)
{
nextAdmin.IsAdmin = true;
SendLocalizedMessage(NewAdmin, Translation.Arguments("player", nextAdmin.Name));
SendLocalizedMessage(NewAdmin, FluentBundle.Arguments("player", nextAdmin.Name));
}
}
@@ -1302,7 +1302,7 @@ namespace OpenRA.Server
{
lock (LobbyInfo)
{
WriteLineWithTimeStamp(TranslationProvider.GetString(GameStarted));
WriteLineWithTimeStamp(FluentProvider.GetString(GameStarted));
// Drop any players who are not ready
foreach (var c in Conns.Where(c => !c.Validated || GetClient(c).IsInvalid).ToArray())

View File

@@ -17,22 +17,22 @@ namespace OpenRA.Server
{
public sealed class VoteKickTracker
{
[TranslationReference("kickee")]
[FluentReference("kickee")]
const string InsufficientVotes = "notification-insufficient-votes-to-kick";
[TranslationReference]
[FluentReference]
const string AlreadyVoted = "notification-kick-already-voted";
[TranslationReference("kicker", "kickee")]
[FluentReference("kicker", "kickee")]
const string VoteKickStarted = "notification-vote-kick-started";
[TranslationReference]
[FluentReference]
const string UnableToStartAVote = "notification-unable-to-start-a-vote";
[TranslationReference("kickee", "percentage")]
[FluentReference("kickee", "percentage")]
const string VoteKickProgress = "notification-vote-kick-in-progress";
[TranslationReference("kickee")]
[FluentReference("kickee")]
const string VoteKickEnded = "notification-vote-kick-ended";
readonly Dictionary<int, bool> voteTracker = new();
@@ -107,7 +107,7 @@ namespace OpenRA.Server
if (!kickee.IsObserver && !server.HasClientWonOrLost(kickee))
{
// Vote kick cannot be the sole deciding factor for a game.
server.SendLocalizedMessageTo(conn, InsufficientVotes, Translation.Arguments("kickee", kickee.Name));
server.SendLocalizedMessageTo(conn, InsufficientVotes, FluentBundle.Arguments("kickee", kickee.Name));
EndKickVote();
return false;
}
@@ -135,7 +135,7 @@ namespace OpenRA.Server
Log.Write("server", $"Vote kick started on {kickeeID}.");
voteKickTimer = Stopwatch.StartNew();
server.SendLocalizedMessage(VoteKickStarted, Translation.Arguments("kicker", kicker.Name, "kickee", kickee.Name));
server.SendLocalizedMessage(VoteKickStarted, FluentBundle.Arguments("kicker", kicker.Name, "kickee", kickee.Name));
server.DispatchServerOrdersToClients(new Order("StartKickVote", null, false) { ExtraData = (uint)kickeeID }.Serialize());
this.kickee = (kickee, kickeeConn);
voteKickerStarter = (kicker, conn);
@@ -168,7 +168,7 @@ namespace OpenRA.Server
}
var votesNeeded = eligiblePlayers / 2 + 1;
server.SendLocalizedMessage(VoteKickProgress, Translation.Arguments(
server.SendLocalizedMessage(VoteKickProgress, FluentBundle.Arguments(
"kickee", kickee.Name,
"percentage", votesFor * 100 / eligiblePlayers));
@@ -210,7 +210,7 @@ namespace OpenRA.Server
return;
if (sendMessage)
server.SendLocalizedMessage(VoteKickEnded, Translation.Arguments("kickee", kickee.Client.Name));
server.SendLocalizedMessage(VoteKickEnded, FluentBundle.Arguments("kickee", kickee.Client.Name));
server.DispatchServerOrdersToClients(new Order("EndKickVote", null, false) { ExtraData = (uint)kickee.Client.Index }.Serialize());