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

@@ -25,40 +25,40 @@ using OpenRA.Traits;
namespace OpenRA
{
[AttributeUsage(AttributeTargets.Field)]
public sealed class TranslationReferenceAttribute : Attribute
public sealed class FluentReferenceAttribute : Attribute
{
public readonly bool Optional;
public readonly string[] RequiredVariableNames;
public readonly LintDictionaryReference DictionaryReference;
public TranslationReferenceAttribute() { }
public FluentReferenceAttribute() { }
public TranslationReferenceAttribute(params string[] requiredVariableNames)
public FluentReferenceAttribute(params string[] requiredVariableNames)
{
RequiredVariableNames = requiredVariableNames;
}
public TranslationReferenceAttribute(LintDictionaryReference dictionaryReference = LintDictionaryReference.None)
public FluentReferenceAttribute(LintDictionaryReference dictionaryReference = LintDictionaryReference.None)
{
DictionaryReference = dictionaryReference;
}
public TranslationReferenceAttribute(bool optional)
public FluentReferenceAttribute(bool optional)
{
Optional = optional;
}
}
public class Translation
public class FluentBundle
{
readonly FluentBundle bundle;
readonly Linguini.Bundle.FluentBundle bundle;
public Translation(string language, string[] translations, IReadOnlyFileSystem fileSystem)
: this(language, translations, fileSystem, error => Log.Write("debug", error.Message)) { }
public FluentBundle(string language, string[] paths, IReadOnlyFileSystem fileSystem)
: this(language, paths, fileSystem, error => Log.Write("debug", error.Message)) { }
public Translation(string language, string[] translations, IReadOnlyFileSystem fileSystem, Action<ParseError> onError)
public FluentBundle(string language, string[] paths, IReadOnlyFileSystem fileSystem, Action<ParseError> onError)
{
if (translations == null || translations.Length == 0)
if (paths == null || paths.Length == 0)
return;
bundle = LinguiniBuilder.Builder()
@@ -68,10 +68,10 @@ namespace OpenRA
.UseConcurrent()
.UncheckedBuild();
ParseTranslations(language, translations, fileSystem, onError);
Load(language, paths, fileSystem, onError);
}
public Translation(string language, string text, Action<ParseError> onError)
public FluentBundle(string language, string text, Action<ParseError> onError)
{
var parser = new LinguiniParser(text);
var resource = parser.Parse();
@@ -88,16 +88,16 @@ namespace OpenRA
bundle.AddResourceOverriding(resource);
}
void ParseTranslations(string language, string[] translations, IReadOnlyFileSystem fileSystem, Action<ParseError> onError)
void Load(string language, string[] paths, IReadOnlyFileSystem fileSystem, Action<ParseError> onError)
{
// Always load english strings to provide a fallback for missing translations.
// It is important to load the english files first so the chosen language's files can override them.
var paths = translations.Where(t => t.EndsWith("en.ftl", StringComparison.Ordinal)).ToList();
foreach (var t in translations)
var resolvedPaths = paths.Where(t => t.EndsWith("en.ftl", StringComparison.Ordinal)).ToList();
foreach (var t in paths)
if (t.EndsWith($"{language}.ftl", StringComparison.Ordinal))
paths.Add(t);
resolvedPaths.Add(t);
foreach (var path in paths.Distinct())
foreach (var path in resolvedPaths.Distinct())
{
var stream = fileSystem.Open(path);
using (var reader = new StreamReader(stream))
@@ -140,13 +140,13 @@ namespace OpenRA
var result = bundle.TryGetAttrMessage(key, fluentArguments, out var errors, out value);
foreach (var error in errors)
Log.Write("debug", $"Translation of {key}: {error}");
Log.Write("debug", $"FluentBundle of {key}: {error}");
return result;
}
catch (Exception)
{
Log.Write("debug", $"Failed translation: {key}");
Log.Write("debug", $"FluentBundle of {key}: threw exception");
value = null;
return false;

View File

@@ -13,7 +13,7 @@ using Linguini.Shared.Types.Bundle;
namespace OpenRA
{
public static class TranslationExts
public static class FluentExts
{
public static IFluentType ToFluentType(this object value)
{

View File

@@ -14,20 +14,20 @@ using OpenRA.FileSystem;
namespace OpenRA
{
public static class TranslationProvider
public static class FluentProvider
{
// Ensure thread-safety.
static readonly object SyncObject = new();
static Translation modTranslation;
static Translation mapTranslation;
static FluentBundle modFluentBundle;
static FluentBundle mapFluentBundle;
public static void Initialize(ModData modData, IReadOnlyFileSystem fileSystem)
{
lock (SyncObject)
{
modTranslation = new Translation(Game.Settings.Player.Language, modData.Manifest.Translations, fileSystem);
mapTranslation = fileSystem is Map map && map.TranslationDefinitions != null
? new Translation(Game.Settings.Player.Language, FieldLoader.GetValue<string[]>("value", map.TranslationDefinitions.Value), fileSystem)
modFluentBundle = new FluentBundle(Game.Settings.Player.Language, modData.Manifest.Translations, fileSystem);
mapFluentBundle = fileSystem is Map map && map.TranslationDefinitions != null
? new FluentBundle(Game.Settings.Player.Language, FieldLoader.GetValue<string[]>("value", map.TranslationDefinitions.Value), fileSystem)
: null;
}
}
@@ -36,13 +36,13 @@ namespace OpenRA
{
lock (SyncObject)
{
// By prioritizing mod-level translations we prevent maps from overwriting translation keys. We do not want to
// By prioritizing mod-level fluent bundles we prevent maps from overwriting string keys. We do not want to
// allow maps to change the UI nor any other strings not exposed to the map.
if (modTranslation.TryGetString(key, out var message, args))
if (modFluentBundle.TryGetString(key, out var message, args))
return message;
if (mapTranslation != null)
return mapTranslation.GetString(key, args);
if (mapFluentBundle != null)
return mapFluentBundle.GetString(key, args);
return key;
}
@@ -52,12 +52,12 @@ namespace OpenRA
{
lock (SyncObject)
{
// By prioritizing mod-level translations we prevent maps from overwriting translation keys. We do not want to
// By prioritizing mod-level bundle we prevent maps from overwriting string keys. We do not want to
// allow maps to change the UI nor any other strings not exposed to the map.
if (modTranslation.TryGetString(key, out message, args))
if (modFluentBundle.TryGetString(key, out message, args))
return true;
if (mapTranslation != null && mapTranslation.TryGetString(key, out message, args))
if (mapFluentBundle != null && mapFluentBundle.TryGetString(key, out message, args))
return true;
return false;
@@ -69,7 +69,7 @@ namespace OpenRA
{
lock (SyncObject)
{
return modTranslation.TryGetString(key, out message, args);
return modFluentBundle.TryGetString(key, out message, args);
}
}
}

View File

@@ -29,7 +29,7 @@ namespace OpenRA
{
public static class Game
{
[TranslationReference("filename")]
[FluentReference("filename")]
const string SavedScreenshot = "notification-saved-screenshot";
public const int TimestepJankThreshold = 250; // Don't catch up for delays larger than 250ms
@@ -595,7 +595,7 @@ namespace OpenRA
Log.Write("debug", "Taking screenshot " + path);
Renderer.SaveScreenshot(path);
TextNotificationsManager.Debug(TranslationProvider.GetString(SavedScreenshot, Translation.Arguments("filename", filename)));
TextNotificationsManager.Debug(FluentProvider.GetString(SavedScreenshot, FluentBundle.Arguments("filename", filename)));
}
}

View File

@@ -19,7 +19,7 @@ namespace OpenRA
{
public class GameInformation
{
[TranslationReference("name", "number")]
[FluentReference("name", "number")]
const string EnumeratedBotName = "enumerated-bot-name";
public string Mod;
@@ -152,9 +152,9 @@ namespace OpenRA
if (player.IsBot)
{
var number = Players.Where(p => p.BotType == player.BotType).ToList().IndexOf(player) + 1;
return TranslationProvider.GetString(EnumeratedBotName,
Translation.Arguments(
"name", TranslationProvider.GetString(player.Name),
return FluentProvider.GetString(EnumeratedBotName,
FluentBundle.Arguments(
"name", FluentProvider.GetString(player.Name),
"number", number));
}

View File

@@ -15,7 +15,7 @@ namespace OpenRA
{
public class GameSpeed
{
[TranslationReference]
[FluentReference]
[FieldLoader.Require]
public readonly string Name;

View File

@@ -91,7 +91,7 @@ namespace OpenRA
public MiniYaml SequenceDefinitions;
public MiniYaml ModelSequenceDefinitions;
public Translation Translation { get; private set; }
public FluentBundle FluentBundle { get; private set; }
public ActorInfo WorldActorInfo { get; private set; }
public ActorInfo PlayerActorInfo { get; private set; }
@@ -122,8 +122,8 @@ namespace OpenRA
SequenceDefinitions = LoadRuleSection(yaml, "Sequences");
ModelSequenceDefinitions = LoadRuleSection(yaml, "ModelSequences");
Translation = yaml.TryGetValue("Translations", out var node) && node != null
? new Translation(Game.Settings.Player.Language, FieldLoader.GetValue<string[]>("value", node.Value), fileSystem)
FluentBundle = yaml.TryGetValue("Translations", out var node) && node != null
? new FluentBundle(Game.Settings.Player.Language, FieldLoader.GetValue<string[]>("value", node.Value), fileSystem)
: null;
try
@@ -224,16 +224,16 @@ namespace OpenRA
public int DownloadPercentage { get; private set; }
/// <summary>
/// Functionality mirrors <see cref="TranslationProvider.GetString"/>, except instead of using
/// loaded <see cref="Map"/>'s translations as backup, we use this <see cref="MapPreview"/>'s.
/// Functionality mirrors <see cref="FluentProvider.GetString"/>, except instead of using
/// loaded <see cref="Map"/>'s fluent bundle as backup, we use this <see cref="MapPreview"/>'s.
/// </summary>
public string GetLocalisedString(string key, IDictionary<string, object> args = null)
{
// PERF: instead of loading mod level Translation per each MapPreview, reuse the already loaded one in TranslationProvider.
if (TranslationProvider.TryGetModString(key, out var message, args))
// PERF: instead of loading mod level strings per each MapPreview, reuse the already loaded one in FluentProvider.
if (FluentProvider.TryGetModString(key, out var message, args))
return message;
return innerData.Translation?.GetString(key, args) ?? key;
return innerData.FluentBundle?.GetString(key, args) ?? key;
}
Sprite minimap;

View File

@@ -130,7 +130,7 @@ namespace OpenRA
// horribly when you use ModData in unexpected ways.
ChromeMetrics.Initialize(this);
ChromeProvider.Initialize(this);
TranslationProvider.Initialize(this, fileSystem);
FluentProvider.Initialize(this, fileSystem);
Game.Sound.Initialize(SoundLoaders, fileSystem);

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Network
}
}
public class LocalizedMessage
public class FluentMessage
{
public const int ProtocolVersion = 1;
@@ -81,7 +81,7 @@ namespace OpenRA.Network
return arguments;
}
public LocalizedMessage(MiniYaml yaml)
public FluentMessage(MiniYaml yaml)
{
// Let the FieldLoader do the dirty work of loading the public fields.
FieldLoader.Load(this, yaml);
@@ -105,7 +105,7 @@ namespace OpenRA.Network
}
return new MiniYaml("", root)
.ToLines("LocalizedMessage")
.ToLines("FluentMessage")
.JoinWith("\n");
}
}

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Network
{
const OrderPacket ClientDisconnected = null;
[TranslationReference("frame")]
[FluentReference("frame")]
const string DesyncCompareLogs = "notification-desync-compare-logs";
readonly SyncReport syncReport;
@@ -91,7 +91,7 @@ namespace OpenRA.Network
World.OutOfSync();
IsOutOfSync = true;
TextNotificationsManager.AddSystemLine(DesyncCompareLogs, Translation.Arguments("frame", frame));
TextNotificationsManager.AddSystemLine(DesyncCompareLogs, FluentBundle.Arguments("frame", frame));
}
public void StartGame()

View File

@@ -20,22 +20,22 @@ namespace OpenRA.Network
{
public const int ChatMessageMaxLength = 2500;
[TranslationReference("player")]
[FluentReference("player")]
const string Joined = "notification-joined";
[TranslationReference("player")]
[FluentReference("player")]
const string Left = "notification-lobby-disconnected";
[TranslationReference]
[FluentReference]
const string GameStarted = "notification-game-has-started";
[TranslationReference]
[FluentReference]
const string GameSaved = "notification-game-saved";
[TranslationReference("player")]
[FluentReference("player")]
const string GamePaused = "notification-game-paused";
[TranslationReference("player")]
[FluentReference("player")]
const string GameUnpaused = "notification-game-unpaused";
public static int? KickVoteTarget { get; internal set; }
@@ -56,8 +56,8 @@ namespace OpenRA.Network
TextNotificationsManager.AddSystemLine(order.TargetString);
break;
// Client side translated server message
case "LocalizedMessage":
// Client side resolved server message
case "FluentMessage":
{
if (string.IsNullOrEmpty(order.TargetString))
break;
@@ -65,7 +65,7 @@ namespace OpenRA.Network
var yaml = MiniYaml.FromString(order.TargetString, order.OrderString);
foreach (var node in yaml)
{
var localizedMessage = new LocalizedMessage(node.Value);
var localizedMessage = new FluentMessage(node.Value);
if (localizedMessage.Key == Joined)
TextNotificationsManager.AddPlayerJoinedLine(localizedMessage.Key, localizedMessage.Arguments);
else if (localizedMessage.Key == Left)
@@ -231,7 +231,7 @@ namespace OpenRA.Network
break;
if (orderManager.World.Paused != pause && world != null && world.LobbyInfo.NonBotClients.Count() > 1)
TextNotificationsManager.AddSystemLine(pause ? GamePaused : GameUnpaused, Translation.Arguments("player", client.Name));
TextNotificationsManager.AddSystemLine(pause ? GamePaused : GameUnpaused, FluentBundle.Arguments("player", client.Name));
orderManager.World.Paused = pause;
orderManager.World.PredictedPaused = pause;

View File

@@ -38,7 +38,7 @@ namespace OpenRA
public class Player : IScriptBindable, IScriptNotifyBind, ILuaTableBinding, ILuaEqualityBinding, ILuaToStringBinding
{
[TranslationReference("name", "number")]
[FluentReference("name", "number")]
const string EnumeratedBotName = "enumerated-bot-name";
public readonly Actor PlayerActor;
@@ -238,8 +238,8 @@ namespace OpenRA
{
var botInfo = botInfos.First(b => b.Type == BotType);
var botsOfSameType = World.Players.Where(c => c.BotType == BotType).ToArray();
return TranslationProvider.GetString(EnumeratedBotName,
Translation.Arguments("name", TranslationProvider.GetString(botInfo.Name),
return FluentProvider.GetString(EnumeratedBotName,
FluentBundle.Arguments("name", FluentProvider.GetString(botInfo.Name),
"number", botsOfSameType.IndexOf(this) + 1));
}

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

View File

@@ -38,12 +38,12 @@ namespace OpenRA
return;
if (player == null || player == player.World.LocalPlayer)
AddTextNotification(TextNotificationPool.Transients, SystemClientId, SystemMessageLabel, TranslationProvider.GetString(text));
AddTextNotification(TextNotificationPool.Transients, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text));
}
public static void AddFeedbackLine(string text, Dictionary<string, object> arguments = null)
{
AddTextNotification(TextNotificationPool.Feedback, SystemClientId, SystemMessageLabel, TranslationProvider.GetString(text, arguments));
AddTextNotification(TextNotificationPool.Feedback, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text, arguments));
}
public static void AddMissionLine(string prefix, string text, Color? prefixColor = null)
@@ -53,17 +53,17 @@ namespace OpenRA
public static void AddPlayerJoinedLine(string text, Dictionary<string, object> arguments = null)
{
AddTextNotification(TextNotificationPool.Join, SystemClientId, SystemMessageLabel, TranslationProvider.GetString(text, arguments));
AddTextNotification(TextNotificationPool.Join, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text, arguments));
}
public static void AddPlayerLeftLine(string text, Dictionary<string, object> arguments = null)
{
AddTextNotification(TextNotificationPool.Leave, SystemClientId, SystemMessageLabel, TranslationProvider.GetString(text, arguments));
AddTextNotification(TextNotificationPool.Leave, SystemClientId, SystemMessageLabel, FluentProvider.GetString(text, arguments));
}
public static void AddSystemLine(string text, Dictionary<string, object> arguments = null)
{
AddSystemLine(SystemMessageLabel, TranslationProvider.GetString(text, arguments));
AddSystemLine(SystemMessageLabel, FluentProvider.GetString(text, arguments));
}
public static void AddSystemLine(string prefix, string text)

View File

@@ -18,11 +18,11 @@ namespace OpenRA.Traits
[Desc("Required for shroud and fog visibility checks. Add this to the player actor.")]
public class ShroudInfo : TraitInfo, ILobbyOptions
{
[TranslationReference]
[FluentReference]
[Desc("Descriptive label for the fog checkbox in the lobby.")]
public readonly string FogCheckboxLabel = "checkbox-fog-of-war.label";
[TranslationReference]
[FluentReference]
[Desc("Tooltip description for the fog checkbox in the lobby.")]
public readonly string FogCheckboxDescription = "checkbox-fog-of-war.description";
@@ -38,11 +38,11 @@ namespace OpenRA.Traits
[Desc("Display order for the fog checkbox in the lobby.")]
public readonly int FogCheckboxDisplayOrder = 0;
[TranslationReference]
[FluentReference]
[Desc("Descriptive label for the explored map checkbox in the lobby.")]
public readonly string ExploredMapCheckboxLabel = "checkbox-explored-map.label";
[TranslationReference]
[FluentReference]
[Desc("Tooltip description for the explored map checkbox in the lobby.")]
public readonly string ExploredMapCheckboxDescription = "checkbox-explored-map.description";

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Traits
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
public class FactionInfo : TraitInfo<Faction>
{
[TranslationReference]
[FluentReference]
[Desc("This is the name exposed to the players.")]
public readonly string Name = null;
@@ -30,7 +30,7 @@ namespace OpenRA.Traits
[Desc("The side that the faction belongs to. For example, England belongs to the 'Allies' side.")]
public readonly string Side = null;
[TranslationReference(optional: true)]
[FluentReference(optional: true)]
[Desc("This is shown in the lobby as a tooltip.")]
public readonly string Description = null;