diff --git a/OpenRA.Game/Translation.cs b/OpenRA.Game/FluentBundle.cs similarity index 75% rename from OpenRA.Game/Translation.cs rename to OpenRA.Game/FluentBundle.cs index a12039b607..35e7e51023 100644 --- a/OpenRA.Game/Translation.cs +++ b/OpenRA.Game/FluentBundle.cs @@ -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 onError) + public FluentBundle(string language, string[] paths, IReadOnlyFileSystem fileSystem, Action 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 onError) + public FluentBundle(string language, string text, Action 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 onError) + void Load(string language, string[] paths, IReadOnlyFileSystem fileSystem, Action 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; diff --git a/OpenRA.Game/TranslationExts.cs b/OpenRA.Game/FluentExts.cs similarity index 96% rename from OpenRA.Game/TranslationExts.cs rename to OpenRA.Game/FluentExts.cs index b0887f9327..255140c7b3 100644 --- a/OpenRA.Game/TranslationExts.cs +++ b/OpenRA.Game/FluentExts.cs @@ -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) { diff --git a/OpenRA.Game/TranslationProvider.cs b/OpenRA.Game/FluentProvider.cs similarity index 58% rename from OpenRA.Game/TranslationProvider.cs rename to OpenRA.Game/FluentProvider.cs index c8b7c387b3..669abb092c 100644 --- a/OpenRA.Game/TranslationProvider.cs +++ b/OpenRA.Game/FluentProvider.cs @@ -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("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("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); } } } diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 636a04e1c1..aa21187ac2 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -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))); } } diff --git a/OpenRA.Game/GameInformation.cs b/OpenRA.Game/GameInformation.cs index c315948345..8d7e1988c8 100644 --- a/OpenRA.Game/GameInformation.cs +++ b/OpenRA.Game/GameInformation.cs @@ -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)); } diff --git a/OpenRA.Game/GameSpeed.cs b/OpenRA.Game/GameSpeed.cs index ccb93d6c5a..f8943cf181 100644 --- a/OpenRA.Game/GameSpeed.cs +++ b/OpenRA.Game/GameSpeed.cs @@ -15,7 +15,7 @@ namespace OpenRA { public class GameSpeed { - [TranslationReference] + [FluentReference] [FieldLoader.Require] public readonly string Name; diff --git a/OpenRA.Game/Map/MapPreview.cs b/OpenRA.Game/Map/MapPreview.cs index 8251f34560..4b1a9afb1d 100644 --- a/OpenRA.Game/Map/MapPreview.cs +++ b/OpenRA.Game/Map/MapPreview.cs @@ -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("value", node.Value), fileSystem) + FluentBundle = yaml.TryGetValue("Translations", out var node) && node != null + ? new FluentBundle(Game.Settings.Player.Language, FieldLoader.GetValue("value", node.Value), fileSystem) : null; try @@ -224,16 +224,16 @@ namespace OpenRA public int DownloadPercentage { get; private set; } /// - /// Functionality mirrors , except instead of using - /// loaded 's translations as backup, we use this 's. + /// Functionality mirrors , except instead of using + /// loaded 's fluent bundle as backup, we use this 's. /// public string GetLocalisedString(string key, IDictionary 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; diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index f16cea969b..35155b26aa 100644 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -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); diff --git a/OpenRA.Game/Network/LocalizedMessage.cs b/OpenRA.Game/Network/FluentMessage.cs similarity index 96% rename from OpenRA.Game/Network/LocalizedMessage.cs rename to OpenRA.Game/Network/FluentMessage.cs index 5b102b497e..ad3a29b984 100644 --- a/OpenRA.Game/Network/LocalizedMessage.cs +++ b/OpenRA.Game/Network/FluentMessage.cs @@ -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"); } } diff --git a/OpenRA.Game/Network/OrderManager.cs b/OpenRA.Game/Network/OrderManager.cs index 7c504e88e4..f00bf330ae 100644 --- a/OpenRA.Game/Network/OrderManager.cs +++ b/OpenRA.Game/Network/OrderManager.cs @@ -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() diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index a8cc6ea312..11482eab70 100644 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -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; diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index 18b0bfeb96..c2bf3d3ea9 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -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)); } diff --git a/OpenRA.Game/Server/PlayerMessageTracker.cs b/OpenRA.Game/Server/PlayerMessageTracker.cs index 3ce1528ef8..1b36044576 100644 --- a/OpenRA.Game/Server/PlayerMessageTracker.cs +++ b/OpenRA.Game/Server/PlayerMessageTracker.cs @@ -16,7 +16,7 @@ namespace OpenRA.Server { sealed class PlayerMessageTracker { - [TranslationReference("remaining")] + [FluentReference("remaining")] const string ChatTemporaryDisabled = "notification-chat-temp-disabled"; readonly Dictionary> 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; } diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index ed07e9ffb5..3a6969711a 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -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 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 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()) diff --git a/OpenRA.Game/Server/VoteKickTracker.cs b/OpenRA.Game/Server/VoteKickTracker.cs index 32717d77b3..27f418a55c 100644 --- a/OpenRA.Game/Server/VoteKickTracker.cs +++ b/OpenRA.Game/Server/VoteKickTracker.cs @@ -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 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()); diff --git a/OpenRA.Game/TextNotificationsManager.cs b/OpenRA.Game/TextNotificationsManager.cs index 54c83890ab..469a5ab6e4 100644 --- a/OpenRA.Game/TextNotificationsManager.cs +++ b/OpenRA.Game/TextNotificationsManager.cs @@ -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 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 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 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 arguments = null) { - AddSystemLine(SystemMessageLabel, TranslationProvider.GetString(text, arguments)); + AddSystemLine(SystemMessageLabel, FluentProvider.GetString(text, arguments)); } public static void AddSystemLine(string prefix, string text) diff --git a/OpenRA.Game/Traits/Player/Shroud.cs b/OpenRA.Game/Traits/Player/Shroud.cs index cfb96c0b59..95f547b3c3 100644 --- a/OpenRA.Game/Traits/Player/Shroud.cs +++ b/OpenRA.Game/Traits/Player/Shroud.cs @@ -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"; diff --git a/OpenRA.Game/Traits/World/Faction.cs b/OpenRA.Game/Traits/World/Faction.cs index cd93bf8a6a..63f21a98b8 100644 --- a/OpenRA.Game/Traits/World/Faction.cs +++ b/OpenRA.Game/Traits/World/Faction.cs @@ -17,7 +17,7 @@ namespace OpenRA.Traits [TraitLocation(SystemActors.World | SystemActors.EditorWorld)] public class FactionInfo : TraitInfo { - [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; diff --git a/OpenRA.Mods.Cnc/Installer/ExtractMixSourceAction.cs b/OpenRA.Mods.Cnc/Installer/ExtractMixSourceAction.cs index 4f69d7f7c8..494bc6bff9 100644 --- a/OpenRA.Mods.Cnc/Installer/ExtractMixSourceAction.cs +++ b/OpenRA.Mods.Cnc/Installer/ExtractMixSourceAction.cs @@ -51,13 +51,13 @@ namespace OpenRA.Mods.Cnc.Installer Action onProgress = null; if (stream.Length < InstallFromSourceLogic.ShowPercentageThreshold) - updateMessage(TranslationProvider.GetString( + updateMessage(FluentProvider.GetString( InstallFromSourceLogic.Extracing, - Translation.Arguments("filename", displayFilename))); + FluentBundle.Arguments("filename", displayFilename))); else - onProgress = b => updateMessage(TranslationProvider.GetString( + onProgress = b => updateMessage(FluentProvider.GetString( InstallFromSourceLogic.ExtractingProgress, - Translation.Arguments("filename", displayFilename, "progress", 100 * b / stream.Length))); + FluentBundle.Arguments("filename", displayFilename, "progress", 100 * b / stream.Length))); using (var target = File.OpenWrite(targetPath)) { diff --git a/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForCash.cs b/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForCash.cs index 4c0cb4f867..dc1afa334a 100644 --- a/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForCash.cs +++ b/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForCash.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Sound the victim will hear when they get robbed.")] public readonly string InfiltratedNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification the victim will see when they get robbed.")] public readonly string InfiltratedTextNotification = null; @@ -51,7 +51,7 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Sound the perpetrator will hear after successful infiltration.")] public readonly string InfiltrationNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification the perpetrator will see after successful infiltration.")] public readonly string InfiltrationTextNotification = null; diff --git a/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForExploration.cs b/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForExploration.cs index c13c1851d6..381bd661e1 100644 --- a/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForExploration.cs +++ b/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForExploration.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Sound the victim will hear when they get sabotaged.")] public readonly string InfiltratedNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification the victim will see when they get sabotaged.")] public readonly string InfiltratedTextNotification = null; @@ -37,7 +37,7 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Sound the perpetrator will hear after successful infiltration.")] public readonly string InfiltrationNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification the perpetrator will see after successful infiltration.")] public readonly string InfiltrationTextNotification = null; diff --git a/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForPowerOutage.cs b/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForPowerOutage.cs index 03c56f0f71..e90e0c3762 100644 --- a/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForPowerOutage.cs +++ b/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForPowerOutage.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Sound the victim will hear when they get sabotaged.")] public readonly string InfiltratedNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification the victim will see when they get sabotaged.")] public readonly string InfiltratedTextNotification = null; @@ -38,7 +38,7 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Sound the perpetrator will hear after successful infiltration.")] public readonly string InfiltrationNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification the perpetrator will see after successful infiltration.")] public readonly string InfiltrationTextNotification = null; diff --git a/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForSupportPower.cs b/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForSupportPower.cs index a5c7ab4b1c..88b671266a 100644 --- a/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForSupportPower.cs +++ b/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForSupportPower.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Sound the victim will hear when technology gets stolen.")] public readonly string InfiltratedNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification the victim will see when technology gets stolen.")] public readonly string InfiltratedTextNotification = null; @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Sound the perpetrator will hear after successful infiltration.")] public readonly string InfiltrationNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification the perpetrator will see after successful infiltration.")] public readonly string InfiltrationTextNotification = null; diff --git a/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForSupportPowerReset.cs b/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForSupportPowerReset.cs index 2aa1701d4b..5fb58e0358 100644 --- a/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForSupportPowerReset.cs +++ b/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForSupportPowerReset.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Experience to grant to the infiltrating player.")] public readonly int PlayerExperience = 0; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification the victim will see when they get sabotaged.")] public readonly string InfiltratedTextNotification = null; @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Sound the perpetrator will hear after successful infiltration.")] public readonly string InfiltrationNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification the perpetrator will see after successful infiltration.")] public readonly string InfiltrationTextNotification = null; diff --git a/OpenRA.Mods.Cnc/Traits/Infiltration/Infiltrates.cs b/OpenRA.Mods.Cnc/Traits/Infiltration/Infiltrates.cs index 032119535c..d841e8ff90 100644 --- a/OpenRA.Mods.Cnc/Traits/Infiltration/Infiltrates.cs +++ b/OpenRA.Mods.Cnc/Traits/Infiltration/Infiltrates.cs @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Notification to play when a target is infiltrated.")] public readonly string Notification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display when a target is infiltrated.")] public readonly string TextNotification = null; diff --git a/OpenRA.Mods.Cnc/Traits/World/TSVeinsRenderer.cs b/OpenRA.Mods.Cnc/Traits/World/TSVeinsRenderer.cs index 1c18d69598..9928ec834a 100644 --- a/OpenRA.Mods.Cnc/Traits/World/TSVeinsRenderer.cs +++ b/OpenRA.Mods.Cnc/Traits/World/TSVeinsRenderer.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.Traits public readonly string Palette = TileSet.TerrainPaletteInternalName; [FieldLoader.Require] - [TranslationReference] + [FluentReference] [Desc("Resource name used by tooltips.")] public readonly string Name = null; @@ -371,7 +371,7 @@ namespace OpenRA.Mods.Cnc.Traits string IResourceRenderer.GetRenderedResourceTooltip(CPos cell) { if (renderIndices[cell] != null || borders[cell] != Adjacency.None) - return TranslationProvider.GetString(info.Name); + return FluentProvider.GetString(info.Name); return null; } diff --git a/OpenRA.Mods.Common/Commands/ChatCommands.cs b/OpenRA.Mods.Common/Commands/ChatCommands.cs index 85033878b0..fcef570f8b 100644 --- a/OpenRA.Mods.Common/Commands/ChatCommands.cs +++ b/OpenRA.Mods.Common/Commands/ChatCommands.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Commands public class ChatCommands : INotifyChat { - [TranslationReference("name")] + [FluentReference("name")] const string InvalidCommand = "notification-invalid-command"; public Dictionary Commands { get; } @@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Commands if (Commands.TryGetValue(name, out var command)) command.InvokeCommand(name, message[(1 + name.Length)..].Trim()); else - TextNotificationsManager.Debug(TranslationProvider.GetString(InvalidCommand, Translation.Arguments("name", name))); + TextNotificationsManager.Debug(FluentProvider.GetString(InvalidCommand, FluentBundle.Arguments("name", name))); return false; } diff --git a/OpenRA.Mods.Common/Commands/DebugVisualizationCommands.cs b/OpenRA.Mods.Common/Commands/DebugVisualizationCommands.cs index b2825c1218..31568d109c 100644 --- a/OpenRA.Mods.Common/Commands/DebugVisualizationCommands.cs +++ b/OpenRA.Mods.Common/Commands/DebugVisualizationCommands.cs @@ -23,19 +23,19 @@ namespace OpenRA.Mods.Common.Commands public class DebugVisualizationCommands : IChatCommand, IWorldLoaded { - [TranslationReference] + [FluentReference] const string CombatGeometryDescription = "description-combat-geometry"; - [TranslationReference] + [FluentReference] const string RenderGeometryDescription = "description-render-geometry"; - [TranslationReference] + [FluentReference] const string ScreenMapOverlayDescription = "description-screen-map-overlay"; - [TranslationReference] + [FluentReference] const string DepthBufferDescription = "description-depth-buffer"; - [TranslationReference] + [FluentReference] const string ActorTagsOverlayDescripition = "description-actor-tags-overlay"; readonly IDictionary Handler)> commandHandlers = diff --git a/OpenRA.Mods.Common/Commands/DevCommands.cs b/OpenRA.Mods.Common/Commands/DevCommands.cs index 43144f8a1f..0bf8f2228e 100644 --- a/OpenRA.Mods.Common/Commands/DevCommands.cs +++ b/OpenRA.Mods.Common/Commands/DevCommands.cs @@ -24,55 +24,55 @@ namespace OpenRA.Mods.Common.Commands public class DevCommands : IChatCommand, IWorldLoaded { - [TranslationReference] + [FluentReference] const string CheatsDisabled = "notification-cheats-disabled"; - [TranslationReference] + [FluentReference] const string InvalidCashAmount = "notification-invalid-cash-amount"; - [TranslationReference] + [FluentReference] const string ToggleVisiblityDescription = "description-toggle-visibility"; - [TranslationReference] + [FluentReference] const string GiveCashDescription = "description-give-cash"; - [TranslationReference] + [FluentReference] const string GiveCashAllDescription = "description-give-cash-all"; - [TranslationReference] + [FluentReference] const string InstantBuildingDescription = "description-instant-building"; - [TranslationReference] + [FluentReference] const string BuildAnywhereDescription = "description-build-anywhere"; - [TranslationReference] + [FluentReference] const string UnlimitedPowerDescription = "description-unlimited-power"; - [TranslationReference] + [FluentReference] const string EnableTechDescription = "description-enable-tech"; - [TranslationReference] + [FluentReference] const string FastChargeDescription = "description-fast-charge"; - [TranslationReference] + [FluentReference] const string DevCheatAllDescription = "description-dev-cheat-all"; - [TranslationReference] + [FluentReference] const string DevCrashDescription = "description-dev-crash"; - [TranslationReference] + [FluentReference] const string LevelUpActorDescription = "description-levelup-actor"; - [TranslationReference] + [FluentReference] const string PlayerExperienceDescription = "description-player-experience"; - [TranslationReference] + [FluentReference] const string PowerOutageDescription = "description-power-outage"; - [TranslationReference] + [FluentReference] const string KillSelectedActorsDescription = "description-kill-selected-actors"; - [TranslationReference] + [FluentReference] const string DisposeSelectedActorsDescription = "description-dispose-selected-actors"; readonly IDictionary Handler)> commandHandlers = new Dictionary)> @@ -121,7 +121,7 @@ namespace OpenRA.Mods.Common.Commands if (!developerMode.Enabled) { - TextNotificationsManager.Debug(TranslationProvider.GetString(CheatsDisabled)); + TextNotificationsManager.Debug(FluentProvider.GetString(CheatsDisabled)); return; } @@ -149,7 +149,7 @@ namespace OpenRA.Mods.Common.Commands giveCashOrder.ExtraData = (uint)cash; else { - TextNotificationsManager.Debug(TranslationProvider.GetString(InvalidCashAmount)); + TextNotificationsManager.Debug(FluentProvider.GetString(InvalidCashAmount)); return; } diff --git a/OpenRA.Mods.Common/Commands/HelpCommand.cs b/OpenRA.Mods.Common/Commands/HelpCommand.cs index b4eb73c137..1bad4164e1 100644 --- a/OpenRA.Mods.Common/Commands/HelpCommand.cs +++ b/OpenRA.Mods.Common/Commands/HelpCommand.cs @@ -22,13 +22,13 @@ namespace OpenRA.Mods.Common.Commands public class HelpCommand : IChatCommand, IWorldLoaded { - [TranslationReference] + [FluentReference] const string AvailableCommands = "notification-available-commands"; - [TranslationReference] + [FluentReference] const string NoDescription = "description-no-description"; - [TranslationReference] + [FluentReference] const string HelpDescription = "description-help-description"; readonly Dictionary helpDescriptions; @@ -52,12 +52,12 @@ namespace OpenRA.Mods.Common.Commands public void InvokeCommand(string name, string arg) { - TextNotificationsManager.Debug(TranslationProvider.GetString(AvailableCommands)); + TextNotificationsManager.Debug(FluentProvider.GetString(AvailableCommands)); foreach (var key in console.Commands.Keys.OrderBy(k => k)) { if (!helpDescriptions.TryGetValue(key, out var description)) - description = TranslationProvider.GetString(NoDescription); + description = FluentProvider.GetString(NoDescription); TextNotificationsManager.Debug($"{key}: {description}"); } @@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Commands public void RegisterHelp(string name, string description) { - helpDescriptions[name] = TranslationProvider.GetString(description); + helpDescriptions[name] = FluentProvider.GetString(description); } } } diff --git a/OpenRA.Mods.Common/Commands/PlayerCommands.cs b/OpenRA.Mods.Common/Commands/PlayerCommands.cs index 2e56814cbb..b2d41c4a7f 100644 --- a/OpenRA.Mods.Common/Commands/PlayerCommands.cs +++ b/OpenRA.Mods.Common/Commands/PlayerCommands.cs @@ -20,10 +20,10 @@ namespace OpenRA.Mods.Common.Commands public class PlayerCommands : IChatCommand, IWorldLoaded { - [TranslationReference] + [FluentReference] const string PauseDescription = "description-pause-description"; - [TranslationReference] + [FluentReference] const string SurrenderDescription = "description-surrender-description"; World world; diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs index df8818b8fe..61d6b747ef 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs @@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Widgets { public string Text { get; private set; } - [TranslationReference("name", "id")] + [FluentReference("name", "id")] const string AddedActor = "notification-added-actor"; readonly EditorActorLayer editorLayer; @@ -167,8 +167,8 @@ namespace OpenRA.Mods.Common.Widgets public void Do() { editorActorPreview = editorLayer.Add(actor); - Text = TranslationProvider.GetString(AddedActor, - Translation.Arguments("name", editorActorPreview.Info.Name, "id", editorActorPreview.ID)); + Text = FluentProvider.GetString(AddedActor, + FluentBundle.Arguments("name", editorActorPreview.Info.Name, "id", editorActorPreview.ID)); } public void Undo() diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorCopyPasteBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorCopyPasteBrush.cs index 0e75edd20f..fc59e65595 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorCopyPasteBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorCopyPasteBrush.cs @@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common.Widgets sealed class CopyPasteEditorAction : IEditorAction { - [TranslationReference("amount")] + [FluentReference("amount")] const string CopiedTiles = "notification-copied-tiles"; public string Text { get; } @@ -146,7 +146,7 @@ namespace OpenRA.Mods.Common.Widgets undoClipboard = CopySelectionContents(); - Text = TranslationProvider.GetString(CopiedTiles, Translation.Arguments("amount", clipboard.Tiles.Count)); + Text = FluentProvider.GetString(CopiedTiles, FluentBundle.Arguments("amount", clipboard.Tiles.Count)); } /// diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorDefaultBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorDefaultBrush.cs index ca2979a191..604a3a1a25 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorDefaultBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorDefaultBrush.cs @@ -279,13 +279,13 @@ namespace OpenRA.Mods.Common.Widgets sealed class ChangeSelectionAction : IEditorAction { - [TranslationReference("x", "y", "width", "height")] + [FluentReference("x", "y", "width", "height")] const string SelectedArea = "notification-selected-area"; - [TranslationReference("id")] + [FluentReference("id")] const string SelectedActor = "notification-selected-actor"; - [TranslationReference] + [FluentReference] const string ClearedSelection = "notification-cleared-selection"; public string Text { get; } @@ -308,15 +308,15 @@ namespace OpenRA.Mods.Common.Widgets }; if (selection.Area != null) - Text = TranslationProvider.GetString(SelectedArea, Translation.Arguments( + Text = FluentProvider.GetString(SelectedArea, FluentBundle.Arguments( "x", selection.Area.TopLeft.X, "y", selection.Area.TopLeft.Y, "width", selection.Area.BottomRight.X - selection.Area.TopLeft.X, "height", selection.Area.BottomRight.Y - selection.Area.TopLeft.Y)); else if (selection.Actor != null) - Text = TranslationProvider.GetString(SelectedActor, Translation.Arguments("id", selection.Actor.ID)); + Text = FluentProvider.GetString(SelectedActor, FluentBundle.Arguments("id", selection.Actor.ID)); else - Text = TranslationProvider.GetString(ClearedSelection); + Text = FluentProvider.GetString(ClearedSelection); } public void Execute() @@ -337,7 +337,7 @@ namespace OpenRA.Mods.Common.Widgets sealed class RemoveSelectedActorAction : IEditorAction { - [TranslationReference("name", "id")] + [FluentReference("name", "id")] const string RemovedActor = "notification-removed-actor"; public string Text { get; } @@ -360,8 +360,8 @@ namespace OpenRA.Mods.Common.Widgets Actor = defaultBrush.Selection.Actor }; - Text = TranslationProvider.GetString(RemovedActor, - Translation.Arguments("name", actor.Info.Name, "id", actor.ID)); + Text = FluentProvider.GetString(RemovedActor, + FluentBundle.Arguments("name", actor.Info.Name, "id", actor.ID)); } public void Execute() @@ -384,7 +384,7 @@ namespace OpenRA.Mods.Common.Widgets sealed class RemoveActorAction : IEditorAction { - [TranslationReference("name", "id")] + [FluentReference("name", "id")] const string RemovedActor = "notification-removed-actor"; public string Text { get; } @@ -397,8 +397,8 @@ namespace OpenRA.Mods.Common.Widgets this.editorActorLayer = editorActorLayer; this.actor = actor; - Text = TranslationProvider.GetString(RemovedActor, - Translation.Arguments("name", actor.Info.Name, "id", actor.ID)); + Text = FluentProvider.GetString(RemovedActor, + FluentBundle.Arguments("name", actor.Info.Name, "id", actor.ID)); } public void Execute() @@ -419,7 +419,7 @@ namespace OpenRA.Mods.Common.Widgets sealed class MoveActorAction : IEditorAction { - [TranslationReference("id", "x1", "y1", "x2", "y2")] + [FluentReference("id", "x1", "y1", "x2", "y2")] const string MovedActor = "notification-moved-actor"; public string Text { get; private set; } @@ -466,13 +466,13 @@ namespace OpenRA.Mods.Common.Widgets to = worldRenderer.Viewport.ViewToWorld(pixelTo + pixelOffset) + cellOffset; layer.MoveActor(actor, to); - Text = TranslationProvider.GetString(MovedActor, Translation.Arguments("id", actor.ID, "x1", from.X, "y1", from.Y, "x2", to.X, "y2", to.Y)); + Text = FluentProvider.GetString(MovedActor, FluentBundle.Arguments("id", actor.ID, "x1", from.X, "y1", from.Y, "x2", to.X, "y2", to.Y)); } } sealed class RemoveResourceAction : IEditorAction { - [TranslationReference("type")] + [FluentReference("type")] const string RemovedResource = "notification-removed-resource"; public string Text { get; } @@ -487,7 +487,7 @@ namespace OpenRA.Mods.Common.Widgets this.resourceLayer = resourceLayer; this.cell = cell; - Text = TranslationProvider.GetString(RemovedResource, Translation.Arguments("type", resourceType)); + Text = FluentProvider.GetString(RemovedResource, FluentBundle.Arguments("type", resourceType)); } public void Execute() diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorMarkerLayerBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorMarkerLayerBrush.cs index 7a19f6a8ae..989bf036fd 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorMarkerLayerBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorMarkerLayerBrush.cs @@ -98,10 +98,10 @@ namespace OpenRA.Mods.Common.Widgets class PaintMarkerTileEditorAction : IEditorAction { - [TranslationReference("amount", "type")] + [FluentReference("amount", "type")] const string AddedMarkerTiles = "notification-added-marker-tiles"; - [TranslationReference("amount")] + [FluentReference("amount")] const string RemovedMarkerTiles = "notification-removed-marker-tiles"; public string Text { get; private set; } @@ -150,15 +150,15 @@ namespace OpenRA.Mods.Common.Widgets } if (type != null) - Text = TranslationProvider.GetString(AddedMarkerTiles, Translation.Arguments("amount", paintTiles.Count, "type", type)); + Text = FluentProvider.GetString(AddedMarkerTiles, FluentBundle.Arguments("amount", paintTiles.Count, "type", type)); else - Text = TranslationProvider.GetString(RemovedMarkerTiles, Translation.Arguments("amount", paintTiles.Count)); + Text = FluentProvider.GetString(RemovedMarkerTiles, FluentBundle.Arguments("amount", paintTiles.Count)); } } class ClearSelectedMarkerTilesEditorAction : IEditorAction { - [TranslationReference("amount", "type")] + [FluentReference("amount", "type")] const string ClearedSelectedMarkerTiles = "notification-cleared-selected-marker-tiles"; public string Text { get; } @@ -176,7 +176,7 @@ namespace OpenRA.Mods.Common.Widgets tiles = new HashSet(markerLayerOverlay.Tiles[tile]); - Text = TranslationProvider.GetString(ClearedSelectedMarkerTiles, Translation.Arguments("amount", tiles.Count, "type", tile)); + Text = FluentProvider.GetString(ClearedSelectedMarkerTiles, FluentBundle.Arguments("amount", tiles.Count, "type", tile)); } public void Execute() @@ -197,7 +197,7 @@ namespace OpenRA.Mods.Common.Widgets class ClearAllMarkerTilesEditorAction : IEditorAction { - [TranslationReference("amount")] + [FluentReference("amount")] const string ClearedAllMarkerTiles = "notification-cleared-all-marker-tiles"; public string Text { get; } @@ -213,7 +213,7 @@ namespace OpenRA.Mods.Common.Widgets var allTilesCount = tiles.Values.Select(x => x.Count).Sum(); - Text = TranslationProvider.GetString(ClearedAllMarkerTiles, Translation.Arguments("amount", allTilesCount)); + Text = FluentProvider.GetString(ClearedAllMarkerTiles, FluentBundle.Arguments("amount", allTilesCount)); } public void Execute() diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs index 5bec32a633..e910c82cc2 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs @@ -125,7 +125,7 @@ namespace OpenRA.Mods.Common.Widgets sealed class AddResourcesEditorAction : IEditorAction { - [TranslationReference("amount", "type")] + [FluentReference("amount", "type")] const string AddedResource = "notification-added-resource"; public string Text { get; private set; } @@ -168,7 +168,7 @@ namespace OpenRA.Mods.Common.Widgets resourceLayer.ClearResources(resourceCell.Cell); resourceLayer.AddResource(resourceCell.NewResourceType, resourceCell.Cell, resourceLayer.GetMaxDensity(resourceCell.NewResourceType)); cellResources.Add(resourceCell); - Text = TranslationProvider.GetString(AddedResource, Translation.Arguments("amount", cellResources.Count, "type", resourceType)); + Text = FluentProvider.GetString(AddedResource, FluentBundle.Arguments("amount", cellResources.Count, "type", resourceType)); } } } diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs index e9867a6cc4..4bda68e356 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs @@ -172,7 +172,7 @@ namespace OpenRA.Mods.Common.Widgets sealed class PaintTileEditorAction : IEditorAction { - [TranslationReference("id")] + [FluentReference("id")] const string AddedTile = "notification-added-tile"; public string Text { get; } @@ -192,7 +192,7 @@ namespace OpenRA.Mods.Common.Widgets var terrainInfo = (ITemplatedTerrainInfo)map.Rules.TerrainInfo; terrainTemplate = terrainInfo.Templates[template]; - Text = TranslationProvider.GetString(AddedTile, Translation.Arguments("id", terrainTemplate.Id)); + Text = FluentProvider.GetString(AddedTile, FluentBundle.Arguments("id", terrainTemplate.Id)); } public void Execute() @@ -244,7 +244,7 @@ namespace OpenRA.Mods.Common.Widgets sealed class FloodFillEditorAction : IEditorAction { - [TranslationReference("id")] + [FluentReference("id")] const string FilledTile = "notification-filled-tile"; public string Text { get; } @@ -264,7 +264,7 @@ namespace OpenRA.Mods.Common.Widgets var terrainInfo = (ITemplatedTerrainInfo)map.Rules.TerrainInfo; terrainTemplate = terrainInfo.Templates[template]; - Text = TranslationProvider.GetString(FilledTile, Translation.Arguments("id", terrainTemplate.Id)); + Text = FluentProvider.GetString(FilledTile, FluentBundle.Arguments("id", terrainTemplate.Id)); } public void Execute() diff --git a/OpenRA.Mods.Common/Installer/SourceActions/CopySourceAction.cs b/OpenRA.Mods.Common/Installer/SourceActions/CopySourceAction.cs index ff04c424f2..59e22b1647 100644 --- a/OpenRA.Mods.Common/Installer/SourceActions/CopySourceAction.cs +++ b/OpenRA.Mods.Common/Installer/SourceActions/CopySourceAction.cs @@ -44,13 +44,13 @@ namespace OpenRA.Mods.Common.Installer Action onProgress = null; if (length < InstallFromSourceLogic.ShowPercentageThreshold) - updateMessage(TranslationProvider.GetString( + updateMessage(FluentProvider.GetString( InstallFromSourceLogic.CopyingFilename, - Translation.Arguments("filename", displayFilename))); + FluentBundle.Arguments("filename", displayFilename))); else - onProgress = b => updateMessage(TranslationProvider.GetString( + onProgress = b => updateMessage(FluentProvider.GetString( InstallFromSourceLogic.CopyingFilenameProgress, - Translation.Arguments("filename", displayFilename, "progress", 100 * b / length))); + FluentBundle.Arguments("filename", displayFilename, "progress", 100 * b / length))); InstallerUtils.CopyStream(source, target, length, onProgress); } diff --git a/OpenRA.Mods.Common/Installer/SourceActions/ExtractBlastSourceAction.cs b/OpenRA.Mods.Common/Installer/SourceActions/ExtractBlastSourceAction.cs index bfcb49b26d..5246631269 100644 --- a/OpenRA.Mods.Common/Installer/SourceActions/ExtractBlastSourceAction.cs +++ b/OpenRA.Mods.Common/Installer/SourceActions/ExtractBlastSourceAction.cs @@ -68,13 +68,13 @@ namespace OpenRA.Mods.Common.Installer Action onProgress = null; if (length < InstallFromSourceLogic.ShowPercentageThreshold) - updateMessage(TranslationProvider.GetString( + updateMessage(FluentProvider.GetString( InstallFromSourceLogic.Extracing, - Translation.Arguments("filename", displayFilename))); + FluentBundle.Arguments("filename", displayFilename))); else - onProgress = b => updateMessage(TranslationProvider.GetString( + onProgress = b => updateMessage(FluentProvider.GetString( InstallFromSourceLogic.ExtractingProgress, - Translation.Arguments("filename", displayFilename, "progress", 100 * b / length))); + FluentBundle.Arguments("filename", displayFilename, "progress", 100 * b / length))); using (var target = File.OpenWrite(targetPath)) { diff --git a/OpenRA.Mods.Common/Installer/SourceActions/ExtractIscabSourceAction.cs b/OpenRA.Mods.Common/Installer/SourceActions/ExtractIscabSourceAction.cs index 360727d71e..a48c356fc1 100644 --- a/OpenRA.Mods.Common/Installer/SourceActions/ExtractIscabSourceAction.cs +++ b/OpenRA.Mods.Common/Installer/SourceActions/ExtractIscabSourceAction.cs @@ -64,9 +64,9 @@ namespace OpenRA.Mods.Common.Installer { Log.Write("install", $"Extracting {sourcePath} -> {targetPath}"); var displayFilename = Path.GetFileName(Path.GetFileName(targetPath)); - void OnProgress(int percent) => updateMessage(TranslationProvider.GetString( + void OnProgress(int percent) => updateMessage(FluentProvider.GetString( InstallFromSourceLogic.ExtractingProgress, - Translation.Arguments("filename", displayFilename, "progress", percent))); + FluentBundle.Arguments("filename", displayFilename, "progress", percent))); reader.ExtractFile(node.Value.Value, target, OnProgress); } } diff --git a/OpenRA.Mods.Common/Installer/SourceActions/ExtractMscabSourceAction.cs b/OpenRA.Mods.Common/Installer/SourceActions/ExtractMscabSourceAction.cs index b5cc6b8d37..5840a88af9 100644 --- a/OpenRA.Mods.Common/Installer/SourceActions/ExtractMscabSourceAction.cs +++ b/OpenRA.Mods.Common/Installer/SourceActions/ExtractMscabSourceAction.cs @@ -46,9 +46,9 @@ namespace OpenRA.Mods.Common.Installer { Log.Write("install", $"Extracting {sourcePath} -> {targetPath}"); var displayFilename = Path.GetFileName(Path.GetFileName(targetPath)); - void OnProgress(int percent) => updateMessage(TranslationProvider.GetString( + void OnProgress(int percent) => updateMessage(FluentProvider.GetString( InstallFromSourceLogic.ExtractingProgress, - Translation.Arguments("filename", displayFilename, "progress", percent))); + FluentBundle.Arguments("filename", displayFilename, "progress", percent))); reader.ExtractFile(node.Value.Value, target, OnProgress); } } diff --git a/OpenRA.Mods.Common/Installer/SourceActions/ExtractRawSourceAction.cs b/OpenRA.Mods.Common/Installer/SourceActions/ExtractRawSourceAction.cs index 84ec9b996c..2fe4a5d44a 100644 --- a/OpenRA.Mods.Common/Installer/SourceActions/ExtractRawSourceAction.cs +++ b/OpenRA.Mods.Common/Installer/SourceActions/ExtractRawSourceAction.cs @@ -61,11 +61,11 @@ namespace OpenRA.Mods.Common.Installer Action onProgress = null; if (length < InstallFromSourceLogic.ShowPercentageThreshold) - updateMessage(TranslationProvider.GetString(InstallFromSourceLogic.Extracing, Translation.Arguments("filename", displayFilename))); + updateMessage(FluentProvider.GetString(InstallFromSourceLogic.Extracing, FluentBundle.Arguments("filename", displayFilename))); else - onProgress = b => updateMessage(TranslationProvider.GetString( + onProgress = b => updateMessage(FluentProvider.GetString( InstallFromSourceLogic.ExtractingProgress, - Translation.Arguments("filename", displayFilename, "progress", 100 * b / length))); + FluentBundle.Arguments("filename", displayFilename, "progress", 100 * b / length))); using (var target = File.OpenWrite(targetPath)) { diff --git a/OpenRA.Mods.Common/Installer/SourceActions/ExtractZipSourceAction.cs b/OpenRA.Mods.Common/Installer/SourceActions/ExtractZipSourceAction.cs index dda10d42e4..f6c481d95d 100644 --- a/OpenRA.Mods.Common/Installer/SourceActions/ExtractZipSourceAction.cs +++ b/OpenRA.Mods.Common/Installer/SourceActions/ExtractZipSourceAction.cs @@ -49,9 +49,9 @@ namespace OpenRA.Mods.Common.Installer using (var targetStream = File.OpenWrite(targetPath)) sourceStream.CopyTo(targetStream); - updateMessage(TranslationProvider.GetString( + updateMessage(FluentProvider.GetString( InstallFromSourceLogic.ExtractingProgress, - Translation.Arguments("filename", displayFilename, "progress", 100))); + FluentBundle.Arguments("filename", displayFilename, "progress", 100))); extracted.Add(targetPath); } diff --git a/OpenRA.Mods.Common/Lint/CheckTranslationReference.cs b/OpenRA.Mods.Common/Lint/CheckFluentReferences.cs similarity index 66% rename from OpenRA.Mods.Common/Lint/CheckTranslationReference.cs rename to OpenRA.Mods.Common/Lint/CheckFluentReferences.cs index 6d48887ca8..825132d503 100644 --- a/OpenRA.Mods.Common/Lint/CheckTranslationReference.cs +++ b/OpenRA.Mods.Common/Lint/CheckFluentReferences.cs @@ -27,23 +27,23 @@ using OpenRA.Widgets; namespace OpenRA.Mods.Common.Lint { - sealed class CheckTranslationReference : ILintPass, ILintMapPass + sealed class CheckFluentReferences : ILintPass, ILintMapPass { - static readonly Regex TranslationFilenameRegex = new(@"(?[^\/\\]+)\.ftl$"); + static readonly Regex FilenameRegex = new(@"(?[^\/\\]+)\.ftl$"); void ILintMapPass.Run(Action emitError, Action emitWarning, ModData modData, Map map) { if (map.TranslationDefinitions == null) return; - var usedKeys = GetUsedTranslationKeysInMap(map, emitWarning); + var usedKeys = GetUsedFluentKeysInMap(map, emitWarning); foreach (var context in usedKeys.EmptyKeyContexts) - emitWarning($"Empty key in map translation files required by {context}"); + emitWarning($"Empty key in map ftl files required by {context}"); var mapTranslations = FieldLoader.GetValue("value", map.TranslationDefinitions.Value); - foreach (var language in GetTranslationLanguages(modData)) + foreach (var language in GetModLanguages(modData)) { // Check keys and variables are not missing across all language files. // But for maps we don't warn on unused keys. They might be unused on *this* map, @@ -52,20 +52,20 @@ namespace OpenRA.Mods.Common.Lint modData.Manifest.Translations.Concat(mapTranslations), map.Open, usedKeys, language, _ => false, emitError, emitWarning); - var modTranslation = new Translation(language, modData.Manifest.Translations, modData.DefaultFileSystem, _ => { }); - var mapTranslation = new Translation(language, mapTranslations, map, error => emitError(error.Message)); + var modFluentBundle = new FluentBundle(language, modData.Manifest.Translations, modData.DefaultFileSystem, _ => { }); + var mapFluentBundle = new FluentBundle(language, mapTranslations, map, error => emitError(error.Message)); foreach (var group in usedKeys.KeysWithContext) { - if (modTranslation.HasMessage(group.Key)) + if (modFluentBundle.HasMessage(group.Key)) { - if (mapTranslation.HasMessage(group.Key)) - emitWarning($"Key `{group.Key}` in `{language}` language in map translation files already exists in mod translations and will not be used."); + if (mapFluentBundle.HasMessage(group.Key)) + emitWarning($"Key `{group.Key}` in `{language}` language in map ftl files already exists in mod translations and will not be used."); } - else if (!mapTranslation.HasMessage(group.Key)) + else if (!mapFluentBundle.HasMessage(group.Key)) { foreach (var context in group) - emitWarning($"Missing key `{group.Key}` in `{language}` language in map translation files required by {context}"); + emitWarning($"Missing key `{group.Key}` in `{language}` language in map ftl files required by {context}"); } } } @@ -73,15 +73,14 @@ namespace OpenRA.Mods.Common.Lint void ILintPass.Run(Action emitError, Action emitWarning, ModData modData) { - var (usedKeys, testedFields) = GetUsedTranslationKeysInMod(modData); + var (usedKeys, testedFields) = GetUsedFluentKeysInMod(modData); foreach (var context in usedKeys.EmptyKeyContexts) emitWarning($"Empty key in mod translation files required by {context}"); - foreach (var language in GetTranslationLanguages(modData)) + foreach (var language in GetModLanguages(modData)) { - Console.WriteLine($"Testing translation: {language}"); - var translation = new Translation(language, modData.Manifest.Translations, modData.DefaultFileSystem, error => emitError(error.Message)); + Console.WriteLine($"Testing language: {language}"); CheckModWidgets(modData, usedKeys, testedFields); // With the fully populated keys, check keys and variables are not missing and not unused across all language files. @@ -99,32 +98,32 @@ namespace OpenRA.Mods.Common.Lint continue; foreach (var context in group) - emitWarning($"Missing key `{group.Key}` in `{language}` language in mod translation files required by {context}"); + emitWarning($"Missing key `{group.Key}` in `{language}` language in mod ftl files required by {context}"); } } // Check if we couldn't test any fields. const BindingFlags Binding = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; - var allTranslatableFields = modData.ObjectCreator.GetTypes().SelectMany(t => - t.GetFields(Binding).Where(m => Utility.HasAttribute(m))).ToArray(); - var untestedFields = allTranslatableFields.Except(testedFields); + var allFluentFields = modData.ObjectCreator.GetTypes().SelectMany(t => + t.GetFields(Binding).Where(m => Utility.HasAttribute(m))).ToArray(); + var untestedFields = allFluentFields.Except(testedFields); foreach (var field in untestedFields) emitError( - $"Lint pass ({nameof(CheckTranslationReference)}) lacks the know-how to test translatable field " + + $"Lint pass ({nameof(CheckFluentReferences)}) lacks the know-how to test translatable field " + $"`{field.ReflectedType.Name}.{field.Name}` - previous warnings may be incorrect"); } - static IEnumerable GetTranslationLanguages(ModData modData) + static IEnumerable GetModLanguages(ModData modData) { return modData.Manifest.Translations - .Select(filename => TranslationFilenameRegex.Match(filename).Groups["language"].Value) + .Select(filename => FilenameRegex.Match(filename).Groups["language"].Value) .Distinct() .OrderBy(l => l); } - static TranslationKeys GetUsedTranslationKeysInRuleset(Ruleset rules) + static Keys GetUsedFluentKeysInRuleset(Ruleset rules) { - var usedKeys = new TranslationKeys(); + var usedKeys = new Keys(); foreach (var actorInfo in rules.Actors) { foreach (var traitInfo in actorInfo.Value.TraitInfos()) @@ -132,12 +131,12 @@ namespace OpenRA.Mods.Common.Lint var traitType = traitInfo.GetType(); foreach (var field in Utility.GetFields(traitType)) { - var translationReference = Utility.GetCustomAttributes(field, true).SingleOrDefault(); - if (translationReference == null) + var fluentReference = Utility.GetCustomAttributes(field, true).SingleOrDefault(); + if (fluentReference == null) continue; - foreach (var key in LintExts.GetFieldValues(traitInfo, field, translationReference.DictionaryReference)) - usedKeys.Add(key, translationReference, $"Actor `{actorInfo.Key}` trait `{traitType.Name[..^4]}.{field.Name}`"); + foreach (var key in LintExts.GetFieldValues(traitInfo, field, fluentReference.DictionaryReference)) + usedKeys.Add(key, fluentReference, $"Actor `{actorInfo.Key}` trait `{traitType.Name[..^4]}.{field.Name}`"); } } } @@ -149,12 +148,12 @@ namespace OpenRA.Mods.Common.Lint var warheadType = warhead.GetType(); foreach (var field in Utility.GetFields(warheadType)) { - var translationReference = Utility.GetCustomAttributes(field, true).SingleOrDefault(); - if (translationReference == null) + var fluentReference = Utility.GetCustomAttributes(field, true).SingleOrDefault(); + if (fluentReference == null) continue; - foreach (var key in LintExts.GetFieldValues(warhead, field, translationReference.DictionaryReference)) - usedKeys.Add(key, translationReference, $"Weapon `{weapon.Key}` warhead `{warheadType.Name[..^7]}.{field.Name}`"); + foreach (var key in LintExts.GetFieldValues(warhead, field, fluentReference.DictionaryReference)) + usedKeys.Add(key, fluentReference, $"Weapon `{weapon.Key}` warhead `{warheadType.Name[..^7]}.{field.Name}`"); } } } @@ -162,40 +161,40 @@ namespace OpenRA.Mods.Common.Lint return usedKeys; } - static TranslationKeys GetUsedTranslationKeysInMap(Map map, Action emitWarning) + static Keys GetUsedFluentKeysInMap(Map map, Action emitWarning) { - var usedKeys = GetUsedTranslationKeysInRuleset(map.Rules); + var usedKeys = GetUsedFluentKeysInRuleset(map.Rules); var luaScriptInfo = map.Rules.Actors[SystemActors.World].TraitInfoOrDefault(); if (luaScriptInfo != null) { // Matches expressions such as: - // UserInterface.Translate("translation-key") - // UserInterface.Translate("translation-key\"with-escape") - // UserInterface.Translate("translation-key", { ["attribute"] = foo }) - // UserInterface.Translate("translation-key", { ["attribute\"-with-escape"] = foo }) - // UserInterface.Translate("translation-key", { ["attribute1"] = foo, ["attribute2"] = bar }) - // UserInterface.Translate("translation-key", tableVariable) + // UserInterface.Translate("fluent-key") + // UserInterface.Translate("fluent-key\"with-escape") + // UserInterface.Translate("fluent-key", { ["attribute"] = foo }) + // UserInterface.Translate("fluent-key", { ["attribute\"-with-escape"] = foo }) + // UserInterface.Translate("fluent-key", { ["attribute1"] = foo, ["attribute2"] = bar }) + // UserInterface.Translate("fluent-key", tableVariable) // Extracts groups for the 'key' and each 'attr'. // If the table isn't inline like in the last example, extracts it as 'variable'. const string UserInterfaceTranslatePattern = @"UserInterface\s*\.\s*Translate\s*\(" + // UserInterface.Translate( - @"\s*""(?(?:[^""\\]|\\.)+?)""\s*" + // "translation-key" + @"\s*""(?(?:[^""\\]|\\.)+?)""\s*" + // "fluent-key" @"(,\s*({\s*\[\s*""(?(?:[^""\\]|\\.)*?)""\s*\]\s*=\s*.*?" + // { ["attribute1"] = foo @"(\s*,\s*\[\s*""(?(?:[^""\\]|\\.)*?)""\s*\]\s*=\s*.*?)*\s*}\s*)" + // , ["attribute2"] = bar } "|\\s*,\\s*(?.*?))?" + // tableVariable @"\)"; // ) var translateRegex = new Regex(UserInterfaceTranslatePattern); - // The script in mods/common/scripts/utils.lua defines some helpers which accept a translation key + // The script in mods/common/scripts/utils.lua defines some helpers which accept a fluent key // Matches expressions such as: - // AddPrimaryObjective(Player, "translation-key") - // AddSecondaryObjective(Player, "translation-key") - // AddPrimaryObjective(Player, "translation-key\"with-escape") + // AddPrimaryObjective(Player, "fluent-key") + // AddSecondaryObjective(Player, "fluent-key") + // AddPrimaryObjective(Player, "fluent-key\"with-escape") // Extracts groups for the 'key'. const string AddObjectivePattern = @"(AddPrimaryObjective|AddSecondaryObjective)\s*\(" + // AddPrimaryObjective( - @".*?\s*,\s*""(?(?:[^""\\]|\\.)+?)""\s*" + // Player, "translation-key" + @".*?\s*,\s*""(?(?:[^""\\]|\\.)+?)""\s*" + // Player, "fluent-key" @"\)"; // ) var objectiveRegex = new Regex(AddObjectivePattern); @@ -210,7 +209,8 @@ namespace OpenRA.Mods.Common.Lint IEnumerable matches = translateRegex.Matches(scriptText); if (luaScriptInfo.Scripts.Contains("utils.lua")) matches = matches.Concat(objectiveRegex.Matches(scriptText)); - var scriptTranslations = matches.Select(m => + + var references = matches.Select(m => { var key = m.Groups["key"].Value.Replace(@"\""", @""""); var attrs = m.Groups["attr"].Captures.Select(c => c.Value.Replace(@"\""", @"""")).ToArray(); @@ -218,10 +218,11 @@ namespace OpenRA.Mods.Common.Lint var line = scriptText.Take(m.Index).Count(x => x == '\n') + 1; return (Key: key, Attrs: attrs, Variable: variable, Line: line); }).ToArray(); - foreach (var (key, attrs, variable, line) in scriptTranslations) + + foreach (var (key, attrs, variable, line) in references) { var context = $"Script {script}:{line}"; - usedKeys.Add(key, new TranslationReferenceAttribute(attrs), context); + usedKeys.Add(key, new FluentReferenceAttribute(attrs), context); if (variable != "") { @@ -239,22 +240,22 @@ namespace OpenRA.Mods.Common.Lint return usedKeys; } - static (TranslationKeys UsedKeys, List TestedFields) GetUsedTranslationKeysInMod(ModData modData) + static (Keys UsedKeys, List TestedFields) GetUsedFluentKeysInMod(ModData modData) { - var usedKeys = GetUsedTranslationKeysInRuleset(modData.DefaultRules); + var usedKeys = GetUsedFluentKeysInRuleset(modData.DefaultRules); var testedFields = new List(); testedFields.AddRange( modData.ObjectCreator.GetTypes() .Where(t => t.IsSubclassOf(typeof(TraitInfo)) || t.IsSubclassOf(typeof(Warhead))) - .SelectMany(t => t.GetFields().Where(f => f.HasAttribute()))); + .SelectMany(t => t.GetFields().Where(f => f.HasAttribute()))); // HACK: Need to hardcode the custom loader for GameSpeeds. var gameSpeeds = modData.Manifest.Get(); var gameSpeedNameField = typeof(GameSpeed).GetField(nameof(GameSpeed.Name)); - var gameSpeedTranslationReference = Utility.GetCustomAttributes(gameSpeedNameField, true)[0]; + var gameSpeedFluentReference = Utility.GetCustomAttributes(gameSpeedNameField, true)[0]; testedFields.Add(gameSpeedNameField); foreach (var speed in gameSpeeds.Speeds.Values) - usedKeys.Add(speed.Name, gameSpeedTranslationReference, $"`{nameof(GameSpeed)}.{nameof(GameSpeed.Name)}`"); + usedKeys.Add(speed.Name, gameSpeedFluentReference, $"`{nameof(GameSpeed)}.{nameof(GameSpeed.Name)}`"); // TODO: linter does not work with LoadUsing foreach (var actorInfo in modData.DefaultRules.Actors) @@ -262,12 +263,12 @@ namespace OpenRA.Mods.Common.Lint foreach (var info in actorInfo.Value.TraitInfos()) { var resourceTypeNameField = typeof(ResourceRendererInfo.ResourceTypeInfo).GetField(nameof(ResourceRendererInfo.ResourceTypeInfo.Name)); - var resourceTypeTranslationReference = Utility.GetCustomAttributes(resourceTypeNameField, true)[0]; + var resourceTypeFluentReference = Utility.GetCustomAttributes(resourceTypeNameField, true)[0]; testedFields.Add(resourceTypeNameField); foreach (var resourceTypes in info.ResourceTypes) usedKeys.Add( resourceTypes.Value.Name, - resourceTypeTranslationReference, + resourceTypeFluentReference, $"`{nameof(ResourceRendererInfo.ResourceTypeInfo)}.{nameof(ResourceRendererInfo.ResourceTypeInfo.Name)}`"); } } @@ -281,47 +282,48 @@ namespace OpenRA.Mods.Common.Lint if (!field.IsLiteral) continue; - var translationReference = Utility.GetCustomAttributes(field, true).SingleOrDefault(); - if (translationReference == null) + var fluentReference = Utility.GetCustomAttributes(field, true).SingleOrDefault(); + if (fluentReference == null) continue; testedFields.Add(field); - var keys = LintExts.GetFieldValues(null, field, translationReference.DictionaryReference); + var keys = LintExts.GetFieldValues(null, field, fluentReference.DictionaryReference); foreach (var key in keys) - usedKeys.Add(key, translationReference, $"`{field.ReflectedType.Name}.{field.Name}`"); + usedKeys.Add(key, fluentReference, $"`{field.ReflectedType.Name}.{field.Name}`"); } } return (usedKeys, testedFields); } - static void CheckModWidgets(ModData modData, TranslationKeys usedKeys, List testedFields) + static void CheckModWidgets(ModData modData, Keys usedKeys, List testedFields) { var chromeLayoutNodes = BuildChromeTree(modData); var widgetTypes = modData.ObjectCreator.GetTypes() .Where(t => t.Name.EndsWith("Widget", StringComparison.InvariantCulture) && t.IsSubclassOf(typeof(Widget))) .ToList(); - var translationReferencesByWidgetField = widgetTypes.SelectMany(t => + + var fluentReferencesByWidgetField = widgetTypes.SelectMany(t => { var widgetName = t.Name[..^6]; return Utility.GetFields(t) .Select(f => { - var attribute = Utility.GetCustomAttributes(f, true).SingleOrDefault(); - return (WidgetName: widgetName, FieldName: f.Name, TranslationReference: attribute); + var attribute = Utility.GetCustomAttributes(f, true).SingleOrDefault(); + return (WidgetName: widgetName, FieldName: f.Name, FluentReference: attribute); }) - .Where(x => x.TranslationReference != null); + .Where(x => x.FluentReference != null); }) .ToDictionary( x => (x.WidgetName, x.FieldName), - x => x.TranslationReference); + x => x.FluentReference); testedFields.AddRange(widgetTypes.SelectMany( - t => Utility.GetFields(t).Where(Utility.HasAttribute))); + t => Utility.GetFields(t).Where(Utility.HasAttribute))); foreach (var node in chromeLayoutNodes) - CheckChrome(node, translationReferencesByWidgetField, usedKeys); + CheckChrome(node, fluentReferencesByWidgetField, usedKeys); } static MiniYamlNode[] BuildChromeTree(ModData modData) @@ -336,38 +338,38 @@ namespace OpenRA.Mods.Common.Lint static void CheckChrome( MiniYamlNode rootNode, - Dictionary<(string WidgetName, string FieldName), TranslationReferenceAttribute> translationReferencesByWidgetField, - TranslationKeys usedKeys) + Dictionary<(string WidgetName, string FieldName), FluentReferenceAttribute> fluentReferencesByWidgetField, + Keys usedKeys) { var nodeType = rootNode.Key.Split('@')[0]; foreach (var childNode in rootNode.Value.Nodes) { var childType = childNode.Key.Split('@')[0]; - if (!translationReferencesByWidgetField.TryGetValue((nodeType, childType), out var translationReference)) + if (!fluentReferencesByWidgetField.TryGetValue((nodeType, childType), out var reference)) continue; var key = childNode.Value.Value; - usedKeys.Add(key, translationReference, $"Widget `{rootNode.Key}` field `{childType}` in {rootNode.Location}"); + usedKeys.Add(key, reference, $"Widget `{rootNode.Key}` field `{childType}` in {rootNode.Location}"); } foreach (var childNode in rootNode.Value.Nodes) if (childNode.Key == "Children") foreach (var n in childNode.Value.Nodes) - CheckChrome(n, translationReferencesByWidgetField, usedKeys); + CheckChrome(n, fluentReferencesByWidgetField, usedKeys); } static HashSet CheckKeys( - IEnumerable translationFiles, Func openFile, TranslationKeys usedKeys, + IEnumerable paths, Func openFile, Keys usedKeys, string language, Func checkUnusedKeysForFile, Action emitError, Action emitWarning) { var keyWithAttrs = new HashSet(); - foreach (var file in translationFiles) + foreach (var path in paths) { - if (!file.EndsWith($"{language}.ftl", StringComparison.Ordinal)) + if (!path.EndsWith($"{language}.ftl", StringComparison.Ordinal)) continue; - var stream = openFile(file); + var stream = openFile(path); using (var reader = new StreamReader(stream)) { var parser = new LinguiniParser(reader); @@ -388,9 +390,9 @@ namespace OpenRA.Mods.Common.Lint foreach (var (node, attributeName) in nodeAndAttributeNames) { keyWithAttrs.Add(attributeName == null ? key : $"{key}.{attributeName}"); - if (checkUnusedKeysForFile(file)) - CheckUnusedKey(key, attributeName, file, usedKeys, emitWarning); - CheckVariables(node, key, attributeName, file, usedKeys, emitError, emitWarning); + if (checkUnusedKeysForFile(path)) + CheckUnusedKey(key, attributeName, path, usedKeys, emitWarning); + CheckVariables(node, key, attributeName, path, usedKeys, emitError, emitWarning); } } } @@ -398,7 +400,7 @@ namespace OpenRA.Mods.Common.Lint return keyWithAttrs; - static void CheckUnusedKey(string key, string attribute, string file, TranslationKeys usedKeys, Action emitWarning) + static void CheckUnusedKey(string key, string attribute, string file, Keys usedKeys, Action emitWarning) { var isAttribute = !string.IsNullOrEmpty(attribute); var keyWithAtrr = isAttribute ? $"{key}.{attribute}" : key; @@ -410,7 +412,7 @@ namespace OpenRA.Mods.Common.Lint } static void CheckVariables( - Pattern node, string key, string attribute, string file, TranslationKeys usedKeys, + Pattern node, string key, string attribute, string file, Keys usedKeys, Action emitError, Action emitWarning) { var isAttribute = !string.IsNullOrEmpty(attribute); @@ -456,26 +458,26 @@ namespace OpenRA.Mods.Common.Lint } } - class TranslationKeys + class Keys { readonly HashSet keys = new(); readonly List<(string Key, string Context)> keysWithContext = new(); readonly Dictionary> requiredVariablesByKey = new(); readonly List contextForEmptyKeys = new(); - public void Add(string key, TranslationReferenceAttribute translationReference, string context) + public void Add(string key, FluentReferenceAttribute fluentReference, string context) { if (key == null) { - if (!translationReference.Optional) + if (!fluentReference.Optional) contextForEmptyKeys.Add(context); return; } - if (translationReference.RequiredVariableNames != null && translationReference.RequiredVariableNames.Length > 0) + if (fluentReference.RequiredVariableNames != null && fluentReference.RequiredVariableNames.Length > 0) { var rv = requiredVariablesByKey.GetOrAdd(key, _ => new HashSet()); - rv.UnionWith(translationReference.RequiredVariableNames); + rv.UnionWith(fluentReference.RequiredVariableNames); } keys.Add(key); diff --git a/OpenRA.Mods.Common/Lint/CheckTranslationSyntax.cs b/OpenRA.Mods.Common/Lint/CheckFluentSyntax.cs similarity index 82% rename from OpenRA.Mods.Common/Lint/CheckTranslationSyntax.cs rename to OpenRA.Mods.Common/Lint/CheckFluentSyntax.cs index b6082a3979..1be773feb9 100644 --- a/OpenRA.Mods.Common/Lint/CheckTranslationSyntax.cs +++ b/OpenRA.Mods.Common/Lint/CheckFluentSyntax.cs @@ -18,7 +18,7 @@ using OpenRA.FileSystem; namespace OpenRA.Mods.Common.Lint { - sealed class CheckTranslationSyntax : ILintPass, ILintMapPass + sealed class CheckFluentSyntax : ILintPass, ILintMapPass { void ILintMapPass.Run(Action emitError, Action emitWarning, ModData modData, Map map) { @@ -33,11 +33,11 @@ namespace OpenRA.Mods.Common.Lint Run(emitError, emitWarning, modData.DefaultFileSystem, modData.Manifest.Translations); } - static void Run(Action emitError, Action emitWarning, IReadOnlyFileSystem fileSystem, string[] translations) + static void Run(Action emitError, Action emitWarning, IReadOnlyFileSystem fileSystem, string[] paths) { - foreach (var file in translations) + foreach (var path in paths) { - var stream = fileSystem.Open(file); + var stream = fileSystem.Open(path); using (var reader = new StreamReader(stream)) { var ids = new List(); @@ -46,12 +46,12 @@ namespace OpenRA.Mods.Common.Lint foreach (var entry in resource.Entries) { if (entry is Junk junk) - emitError($"{junk.GetId()}: {junk.AsStr()} in {file} {junk.Content}."); + emitError($"{junk.GetId()}: {junk.AsStr()} in {path} {junk.Content}."); if (entry is AstMessage message) { if (ids.Contains(message.Id.Name.ToString())) - emitWarning($"Duplicate ID `{message.Id.Name}` in {file}."); + emitWarning($"Duplicate ID `{message.Id.Name}` in {path}."); ids.Add(message.Id.Name.ToString()); } diff --git a/OpenRA.Mods.Common/Scripting/Global/UserInterfaceGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/UserInterfaceGlobal.cs index 2bf4010713..ee10f4d643 100644 --- a/OpenRA.Mods.Common/Scripting/Global/UserInterfaceGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/UserInterfaceGlobal.cs @@ -34,9 +34,9 @@ namespace OpenRA.Mods.Common.Scripting.Global luaLabel.GetColor = () => c; } - [Desc("Translates text into the users language. The translation key must be added to the language files (*.ftl). " + + [Desc("Formats a language string for a given string key defined in the language files (*.ftl). " + "Args can be passed to be substituted into the resulting message.")] - public string Translate(string translationKey, [ScriptEmmyTypeOverride("{ string: any }")] LuaTable args = null) + public string Translate(string key, [ScriptEmmyTypeOverride("{ string: any }")] LuaTable args = null) { if (args != null) { @@ -48,17 +48,17 @@ namespace OpenRA.Mods.Common.Scripting.Global { if (!kv.Key.TryGetClrValue(out var variable) || !kv.Value.TryGetClrValue(out var value)) throw new LuaException( - "Translation arguments requires a table of [\"string\"]=value pairs. " + + "String arguments requires a table of [\"string\"]=value pairs. " + $"Received {kv.Key.WrappedClrType().Name},{kv.Value.WrappedClrType().Name}"); argumentDictionary.Add(variable, value); } } - return TranslationProvider.GetString(translationKey, argumentDictionary); + return FluentProvider.GetString(key, argumentDictionary); } - return TranslationProvider.GetString(translationKey); + return FluentProvider.GetString(key); } } } diff --git a/OpenRA.Mods.Common/Scripting/Properties/GeneralProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/GeneralProperties.cs index 1b8eadf278..c25a3a8505 100644 --- a/OpenRA.Mods.Common/Scripting/Properties/GeneralProperties.cs +++ b/OpenRA.Mods.Common/Scripting/Properties/GeneralProperties.cs @@ -188,7 +188,7 @@ namespace OpenRA.Mods.Common.Scripting if (tooltip == null) return null; - return TranslationProvider.GetString(tooltip.Info.Name); + return FluentProvider.GetString(tooltip.Info.Name); } } diff --git a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs index cdc27e4d19..a12623795c 100644 --- a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs @@ -27,142 +27,142 @@ namespace OpenRA.Mods.Common.Server { public class LobbyCommands : ServerTrait, IInterpretCommand, INotifyServerStart, INotifyServerEmpty, IClientJoined, OpenRA.Server.ITick { - [TranslationReference] + [FluentReference] const string CustomRules = "notification-custom-rules"; - [TranslationReference] + [FluentReference] const string OnlyHostStartGame = "notification-admin-start-game"; - [TranslationReference] + [FluentReference] const string NoStartUntilRequiredSlotsFull = "notification-no-start-until-required-slots-full"; - [TranslationReference] + [FluentReference] const string NoStartWithoutPlayers = "notification-no-start-without-players"; - [TranslationReference] + [FluentReference] const string TwoHumansRequired = "notification-two-humans-required"; - [TranslationReference] + [FluentReference] const string InsufficientEnabledSpawnPoints = "notification-insufficient-enabled-spawn-points"; - [TranslationReference("command")] + [FluentReference("command")] const string MalformedCommand = "notification-malformed-command"; - [TranslationReference] + [FluentReference] const string KickNone = "notification-kick-none"; - [TranslationReference] + [FluentReference] const string NoKickSelf = "notification-kick-self"; - [TranslationReference] + [FluentReference] const string NoKickGameStarted = "notification-no-kick-game-started"; - [TranslationReference("admin", "player")] + [FluentReference("admin", "player")] const string AdminKicked = "notification-admin-kicked"; - [TranslationReference("player")] + [FluentReference("player")] const string Kicked = "notification-kicked"; - [TranslationReference("admin", "player")] + [FluentReference("admin", "player")] const string TempBan = "notification-temp-ban"; - [TranslationReference] + [FluentReference] const string NoTransferAdmin = "notification-admin-transfer-admin"; - [TranslationReference] + [FluentReference] const string EmptySlot = "notification-empty-slot"; - [TranslationReference("admin", "player")] + [FluentReference("admin", "player")] const string MoveSpectators = "notification-move-spectators"; - [TranslationReference("player", "name")] + [FluentReference("player", "name")] const string Nick = "notification-nick-changed"; - [TranslationReference] + [FluentReference] const string StateUnchangedReady = "notification-state-unchanged-ready"; - [TranslationReference("command")] + [FluentReference("command")] const string StateUnchangedGameStarted = "notification-state-unchanged-game-started"; - [TranslationReference("faction")] + [FluentReference("faction")] const string InvalidFactionSelected = "notification-invalid-faction-selected"; - [TranslationReference("factions")] + [FluentReference("factions")] const string SupportedFactions = "notification-supported-factions"; - [TranslationReference] + [FluentReference] const string RequiresHost = "notification-requires-host"; - [TranslationReference] + [FluentReference] const string InvalidBotSlot = "notification-invalid-bot-slot"; - [TranslationReference] + [FluentReference] const string InvalidBotType = "notification-invalid-bot-type"; - [TranslationReference] + [FluentReference] const string HostChangeMap = "notification-admin-change-map"; - [TranslationReference] + [FluentReference] const string UnknownMap = "notification-unknown-map"; - [TranslationReference] + [FluentReference] const string SearchingMap = "notification-searching-map"; - [TranslationReference] + [FluentReference] const string NotAdmin = "notification-admin-change-configuration"; - [TranslationReference] + [FluentReference] const string InvalidConfigurationCommand = "notification-invalid-configuration-command"; - [TranslationReference("option")] + [FluentReference("option")] const string OptionLocked = "notification-option-locked"; - [TranslationReference("player", "map")] + [FluentReference("player", "map")] const string ChangedMap = "notification-changed-map"; - [TranslationReference] + [FluentReference] const string MapBotsDisabled = "notification-map-bots-disabled"; - [TranslationReference("player", "name", "value")] + [FluentReference("player", "name", "value")] const string ValueChanged = "notification-option-changed"; - [TranslationReference] + [FluentReference] const string NoMoveSpectators = "notification-admin-move-spectators"; - [TranslationReference] + [FluentReference] const string AdminOption = "notification-admin-option"; - [TranslationReference("raw")] + [FluentReference("raw")] const string NumberTeams = "notification-error-number-teams"; - [TranslationReference] + [FluentReference] const string AdminClearSpawn = "notification-admin-clear-spawn"; - [TranslationReference] + [FluentReference] const string SpawnOccupied = "notification-spawn-occupied"; - [TranslationReference] + [FluentReference] const string SpawnLocked = "notification-spawn-locked"; - [TranslationReference] + [FluentReference] const string AdminLobbyInfo = "notification-admin-lobby-info"; - [TranslationReference] + [FluentReference] const string InvalidLobbyInfo = "notification-invalid-lobby-info"; - [TranslationReference] + [FluentReference] const string AdminKick = "notification-admin-kick"; - [TranslationReference] + [FluentReference] const string SlotClosed = "notification-slot-closed"; - [TranslationReference("player")] + [FluentReference("player")] const string NewAdmin = "notification-new-admin"; - [TranslationReference] + [FluentReference] const string YouWereKicked = "notification-you-were-kicked"; - [TranslationReference] + [FluentReference] const string VoteKickDisabled = "notification-vote-kick-disabled"; readonly IDictionary> commandHandlers = @@ -224,7 +224,7 @@ namespace OpenRA.Mods.Common.Server if (server.State == ServerState.GameStarted) { - server.SendLocalizedMessageTo(conn, StateUnchangedGameStarted, Translation.Arguments("command", command)); + server.SendLocalizedMessageTo(conn, StateUnchangedGameStarted, FluentBundle.Arguments("command", command)); return false; } else if (client.State == Session.ClientState.Ready && !(command.StartsWith("state", StringComparison.Ordinal) || command == "startgame")) @@ -303,7 +303,7 @@ namespace OpenRA.Mods.Common.Server { if (!Enum.TryParse(s, false, out var state)) { - server.SendLocalizedMessageTo(conn, MalformedCommand, Translation.Arguments("command", "state")); + server.SendLocalizedMessageTo(conn, MalformedCommand, FluentBundle.Arguments("command", "state")); return true; } @@ -399,7 +399,7 @@ namespace OpenRA.Mods.Common.Server return true; } - server.SendLocalizedMessageTo(conn, MalformedCommand, Translation.Arguments("command", "allow_spectate")); + server.SendLocalizedMessageTo(conn, MalformedCommand, FluentBundle.Arguments("command", "allow_spectate")); return true; } @@ -488,7 +488,7 @@ namespace OpenRA.Mods.Common.Server var parts = s.Split(' '); if (parts.Length < 3) { - server.SendLocalizedMessageTo(conn, MalformedCommand, Translation.Arguments("command", "slot_bot")); + server.SendLocalizedMessageTo(conn, MalformedCommand, FluentBundle.Arguments("command", "slot_bot")); return true; } @@ -652,7 +652,7 @@ namespace OpenRA.Mods.Common.Server server.SyncLobbyInfo(); - server.SendLocalizedMessage(ChangedMap, Translation.Arguments("player", client.Name, "map", server.Map.Title)); + server.SendLocalizedMessage(ChangedMap, FluentBundle.Arguments("player", client.Name, "map", server.Map.Title)); if ((server.LobbyInfo.GlobalSettings.MapStatus & Session.MapStatus.UnsafeCustomRules) != 0) server.SendLocalizedMessage(CustomRules); @@ -722,7 +722,7 @@ namespace OpenRA.Mods.Common.Server if (option.IsLocked) { - server.SendLocalizedMessageTo(conn, OptionLocked, Translation.Arguments("option", option.Name)); + server.SendLocalizedMessageTo(conn, OptionLocked, FluentBundle.Arguments("option", option.Name)); return true; } @@ -739,7 +739,7 @@ namespace OpenRA.Mods.Common.Server oo.Value = oo.PreferredValue = split[1]; server.SyncLobbyGlobalSettings(); - server.SendLocalizedMessage(ValueChanged, Translation.Arguments("player", client.Name, "name", option.Name, "value", option.Label(split[1]))); + server.SendLocalizedMessage(ValueChanged, FluentBundle.Arguments("player", client.Name, "name", option.Name, "value", option.Label(split[1]))); foreach (var c in server.LobbyInfo.Clients) c.State = Session.ClientState.NotReady; @@ -768,7 +768,7 @@ namespace OpenRA.Mods.Common.Server foreach (var o in allOptions) { if (o.DefaultValue != server.LobbyInfo.GlobalSettings.LobbyOptions[o.Id].Value) - server.SendLocalizedMessage(ValueChanged, Translation.Arguments( + server.SendLocalizedMessage(ValueChanged, FluentBundle.Arguments( "player", client.Name, "name", o.Name, "value", o.Label(o.DefaultValue))); @@ -805,7 +805,7 @@ namespace OpenRA.Mods.Common.Server if (!Exts.TryParseInt32Invariant(raw, out var teamCount)) { - server.SendLocalizedMessageTo(conn, NumberTeams, Translation.Arguments("raw", raw)); + server.SendLocalizedMessageTo(conn, NumberTeams, FluentBundle.Arguments("raw", raw)); return true; } @@ -850,7 +850,7 @@ namespace OpenRA.Mods.Common.Server var split = s.Split(' '); if (split.Length < 2) { - server.SendLocalizedMessageTo(conn, MalformedCommand, Translation.Arguments("command", "kick")); + server.SendLocalizedMessageTo(conn, MalformedCommand, FluentBundle.Arguments("command", "kick")); return true; } @@ -877,14 +877,14 @@ namespace OpenRA.Mods.Common.Server } Log.Write("server", $"Kicking client {kickClientID}."); - server.SendLocalizedMessage(AdminKicked, Translation.Arguments("admin", client.Name, "player", kickClient.Name)); + server.SendLocalizedMessage(AdminKicked, FluentBundle.Arguments("admin", client.Name, "player", kickClient.Name)); server.SendOrderTo(kickConn, "ServerError", YouWereKicked); server.DropClient(kickConn); if (bool.TryParse(split[1], out var tempBan) && tempBan) { Log.Write("server", $"Temporarily banning client {kickClientID} ({kickClient.IPAddress})."); - server.SendLocalizedMessage(TempBan, Translation.Arguments("admin", client.Name, "player", kickClient.Name)); + server.SendLocalizedMessage(TempBan, FluentBundle.Arguments("admin", client.Name, "player", kickClient.Name)); server.TempBans.Add(kickClient.IPAddress); } @@ -902,7 +902,7 @@ namespace OpenRA.Mods.Common.Server var split = s.Split(' '); if (split.Length != 2) { - server.SendLocalizedMessageTo(conn, MalformedCommand, Translation.Arguments("command", "vote_kick")); + server.SendLocalizedMessageTo(conn, MalformedCommand, FluentBundle.Arguments("command", "vote_kick")); return true; } @@ -930,14 +930,14 @@ namespace OpenRA.Mods.Common.Server if (!bool.TryParse(split[1], out var vote)) { - server.SendLocalizedMessageTo(conn, MalformedCommand, Translation.Arguments("command", "vote_kick")); + server.SendLocalizedMessageTo(conn, MalformedCommand, FluentBundle.Arguments("command", "vote_kick")); return true; } if (server.VoteKickTracker.VoteKick(conn, client, kickConn, kickClient, kickClientID, vote)) { Log.Write("server", $"Kicking client {kickClientID}."); - server.SendLocalizedMessage(Kicked, Translation.Arguments("player", kickClient.Name)); + server.SendLocalizedMessage(Kicked, FluentBundle.Arguments("player", kickClient.Name)); server.SendOrderTo(kickConn, "ServerError", YouWereKicked); server.DropClient(kickConn); @@ -980,7 +980,7 @@ namespace OpenRA.Mods.Common.Server foreach (var b in bots) b.BotControllerClientIndex = newAdminId; - server.SendLocalizedMessage(NewAdmin, Translation.Arguments("player", newAdminClient.Name)); + server.SendLocalizedMessage(NewAdmin, FluentBundle.Arguments("player", newAdminClient.Name)); Log.Write("server", $"{newAdminClient.Name} is now the admin."); server.SyncLobbyClients(); @@ -1014,7 +1014,7 @@ namespace OpenRA.Mods.Common.Server targetClient.Handicap = 0; targetClient.Color = Color.White; targetClient.State = Session.ClientState.NotReady; - server.SendLocalizedMessage(MoveSpectators, Translation.Arguments("admin", client.Name, "player", targetClient.Name)); + server.SendLocalizedMessage(MoveSpectators, FluentBundle.Arguments("admin", client.Name, "player", targetClient.Name)); Log.Write("server", $"{client.Name} moved {targetClient.Name} to spectators."); server.SyncLobbyClients(); CheckAutoStart(server); @@ -1032,7 +1032,7 @@ namespace OpenRA.Mods.Common.Server return true; Log.Write("server", $"Player@{conn.EndPoint} is now known as {sanitizedName}."); - server.SendLocalizedMessage(Nick, Translation.Arguments("player", client.Name, "name", sanitizedName)); + server.SendLocalizedMessage(Nick, FluentBundle.Arguments("player", client.Name, "name", sanitizedName)); client.Name = sanitizedName; server.SyncLobbyClients(); @@ -1062,8 +1062,8 @@ namespace OpenRA.Mods.Common.Server var faction = parts[1]; if (!factions.Contains(faction)) { - server.SendLocalizedMessageTo(conn, InvalidFactionSelected, Translation.Arguments("faction", faction)); - server.SendLocalizedMessageTo(conn, SupportedFactions, Translation.Arguments("factions", factions.JoinWith(", "))); + server.SendLocalizedMessageTo(conn, InvalidFactionSelected, FluentBundle.Arguments("faction", faction)); + server.SendLocalizedMessageTo(conn, SupportedFactions, FluentBundle.Arguments("factions", factions.JoinWith(", "))); return true; } diff --git a/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs b/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs index 76780b2fdb..3c206db210 100644 --- a/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs +++ b/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs @@ -30,22 +30,22 @@ namespace OpenRA.Mods.Common.Server // 1 second (in milliseconds) minimum delay between pings const int RateLimitInterval = 1000; - [TranslationReference] + [FluentReference] const string NoPortForward = "notification-no-port-forward"; - [TranslationReference] + [FluentReference] const string BlacklistedTitle = "notification-blacklisted-server-name"; - [TranslationReference] + [FluentReference] const string InvalidErrorCode = "notification-invalid-error-code"; - [TranslationReference] + [FluentReference] const string Connected = "notification-master-server-connected"; - [TranslationReference] + [FluentReference] const string Error = "notification-master-server-error"; - [TranslationReference] + [FluentReference] const string GameOffline = "notification-game-offline"; static readonly Beacon LanGameBeacon; diff --git a/OpenRA.Mods.Common/ServerTraits/PlayerPinger.cs b/OpenRA.Mods.Common/ServerTraits/PlayerPinger.cs index 53b2e6740f..f0b360749a 100644 --- a/OpenRA.Mods.Common/ServerTraits/PlayerPinger.cs +++ b/OpenRA.Mods.Common/ServerTraits/PlayerPinger.cs @@ -18,16 +18,16 @@ namespace OpenRA.Mods.Common.Server { public class PlayerPinger : ServerTrait, ITick { - [TranslationReference] + [FluentReference] const string PlayerDropped = "notification-player-dropped"; - [TranslationReference("player")] + [FluentReference("player")] const string ConnectionProblems = "notification-connection-problems"; - [TranslationReference("player")] + [FluentReference("player")] const string Timeout = "notification-timeout-dropped"; - [TranslationReference("player", "timeout")] + [FluentReference("player", "timeout")] const string TimeoutIn = "notification-timeout-dropped-in"; const int PingInterval = 5000; // Ping every 5 seconds @@ -69,13 +69,13 @@ namespace OpenRA.Mods.Common.Server { if (!c.TimeoutMessageShown && c.TimeSinceLastResponse > PingInterval * 2) { - server.SendLocalizedMessage(ConnectionProblems, Translation.Arguments("player", client.Name)); + server.SendLocalizedMessage(ConnectionProblems, FluentBundle.Arguments("player", client.Name)); c.TimeoutMessageShown = true; } } else { - server.SendLocalizedMessage(Timeout, Translation.Arguments("player", client.Name)); + server.SendLocalizedMessage(Timeout, FluentBundle.Arguments("player", client.Name)); server.DropClient(c); } } diff --git a/OpenRA.Mods.Common/Traits/Buildable.cs b/OpenRA.Mods.Common/Traits/Buildable.cs index 3ee742f35b..45ae494552 100644 --- a/OpenRA.Mods.Common/Traits/Buildable.cs +++ b/OpenRA.Mods.Common/Traits/Buildable.cs @@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits public readonly int BuildPaletteOrder = 9999; [Desc("Text shown in the production tooltip.")] - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string Description; public static string GetInitialFaction(ActorInfo ai, string defaultFaction) diff --git a/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs b/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs index 7420ed1194..a1922cf36d 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification to play when selecting a primary building.")] public readonly string SelectionNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display when selecting a primary building.")] public readonly string SelectionTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Buildings/ProductionAirdrop.cs b/OpenRA.Mods.Common/Traits/Buildings/ProductionAirdrop.cs index 90adb74d47..0007894235 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/ProductionAirdrop.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/ProductionAirdrop.cs @@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification to play when a unit is delivered.")] public readonly string ReadyAudio = "Reinforce"; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display when a unit is delivered.")] public readonly string ReadyTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs b/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs index 56679bb1f7..34ed96ca53 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs @@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification to play when setting a new rallypoint.")] public readonly string Notification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display when setting a new rallypoint.")] public readonly string TextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs b/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs index f78d44b8d3..73de472272 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs @@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Voice line to play when repairs are started.")] public readonly string RepairingNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Transient text message to display when repairs are started.")] public readonly string RepairingTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Conditions/ToggleConditionOnOrder.cs b/OpenRA.Mods.Common/Traits/Conditions/ToggleConditionOnOrder.cs index deb356536f..a2fed98780 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/ToggleConditionOnOrder.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/ToggleConditionOnOrder.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits [NotificationReference("Speech")] public readonly string EnabledSpeech = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string EnabledTextNotification = null; [NotificationReference("Sounds")] @@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits [NotificationReference("Speech")] public readonly string DisabledSpeech = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string DisabledTextNotification = null; public override object Create(ActorInitializer init) { return new ToggleConditionOnOrder(this); } diff --git a/OpenRA.Mods.Common/Traits/Crates/CrateAction.cs b/OpenRA.Mods.Common/Traits/Crates/CrateAction.cs index 1df5e90949..d75e7c65b6 100644 --- a/OpenRA.Mods.Common/Traits/Crates/CrateAction.cs +++ b/OpenRA.Mods.Common/Traits/Crates/CrateAction.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification to play when the crate is collected.")] public readonly string Notification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display when the crate is collected.")] public readonly string TextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Encyclopedia.cs b/OpenRA.Mods.Common/Traits/Encyclopedia.cs index 51e11c29b5..320ec37f59 100644 --- a/OpenRA.Mods.Common/Traits/Encyclopedia.cs +++ b/OpenRA.Mods.Common/Traits/Encyclopedia.cs @@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits public class EncyclopediaInfo : TraitInfo { [Desc("Explains the purpose in the in-game encyclopedia.")] - [TranslationReference] + [FluentReference] public readonly string Description; [Desc("Number for ordering the list.")] diff --git a/OpenRA.Mods.Common/Traits/GainsExperience.cs b/OpenRA.Mods.Common/Traits/GainsExperience.cs index 82e50746a7..0574aaf72d 100644 --- a/OpenRA.Mods.Common/Traits/GainsExperience.cs +++ b/OpenRA.Mods.Common/Traits/GainsExperience.cs @@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits [NotificationReference("Sounds")] public readonly string LevelUpNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string LevelUpTextNotification = null; public override object Create(ActorInitializer init) { return new GainsExperience(init, this); } diff --git a/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs b/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs index 89c80bb742..f371b1943b 100644 --- a/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs +++ b/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification type to play.")] public readonly string Notification = "BaseAttack"; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display.")] public readonly string TextNotification = null; @@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits "Won't play a notification to allies if this is null.")] public readonly string AllyNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display to allies when under attack.")] public readonly string AllyTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Player/ConquestVictoryConditions.cs b/OpenRA.Mods.Common/Traits/Player/ConquestVictoryConditions.cs index 644fa16032..d80538610c 100644 --- a/OpenRA.Mods.Common/Traits/Player/ConquestVictoryConditions.cs +++ b/OpenRA.Mods.Common/Traits/Player/ConquestVictoryConditions.cs @@ -32,10 +32,10 @@ namespace OpenRA.Mods.Common.Traits public class ConquestVictoryConditions : ITick, INotifyWinStateChanged, INotifyTimeLimit { - [TranslationReference("player")] + [FluentReference("player")] const string PlayerIsVictorious = "notification-player-is-victorious"; - [TranslationReference("player")] + [FluentReference("player")] const string PlayerIsDefeated = "notification-player-is-defeated"; readonly ConquestVictoryConditionsInfo info; @@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Traits if (info.SuppressNotifications) return; - TextNotificationsManager.AddSystemLine(PlayerIsDefeated, Translation.Arguments("player", player.ResolvedPlayerName)); + TextNotificationsManager.AddSystemLine(PlayerIsDefeated, FluentBundle.Arguments("player", player.ResolvedPlayerName)); Game.RunAfterDelay(info.NotificationDelay, () => { if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer) @@ -121,7 +121,7 @@ namespace OpenRA.Mods.Common.Traits if (info.SuppressNotifications) return; - TextNotificationsManager.AddSystemLine(PlayerIsVictorious, Translation.Arguments("player", player.ResolvedPlayerName)); + TextNotificationsManager.AddSystemLine(PlayerIsVictorious, FluentBundle.Arguments("player", player.ResolvedPlayerName)); Game.RunAfterDelay(info.NotificationDelay, () => { if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer) diff --git a/OpenRA.Mods.Common/Traits/Player/DeveloperMode.cs b/OpenRA.Mods.Common/Traits/Player/DeveloperMode.cs index 69d2e00522..16e249c630 100644 --- a/OpenRA.Mods.Common/Traits/Player/DeveloperMode.cs +++ b/OpenRA.Mods.Common/Traits/Player/DeveloperMode.cs @@ -20,11 +20,11 @@ namespace OpenRA.Mods.Common.Traits [Desc("Attach this to the player actor.")] public class DeveloperModeInfo : TraitInfo, ILobbyOptions { - [TranslationReference] + [FluentReference] [Desc("Descriptive label for the developer mode checkbox in the lobby.")] public readonly string CheckboxLabel = "checkbox-debug-menu.label"; - [TranslationReference] + [FluentReference] [Desc("Tooltip description for the developer mode checkbox in the lobby.")] public readonly string CheckboxDescription = "checkbox-debug-menu.description"; @@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.Traits public class DeveloperMode : IResolveOrder, ISync, INotifyCreated, IUnlocksRenderPlayer { - [TranslationReference("cheat", "player", "suffix")] + [FluentReference("cheat", "player", "suffix")] const string CheatUsed = "notification-cheat-used"; readonly DeveloperModeInfo info; @@ -275,8 +275,8 @@ namespace OpenRA.Mods.Common.Traits return; } - var arguments = Translation.Arguments("cheat", order.OrderString, "player", self.Owner.ResolvedPlayerName, "suffix", debugSuffix); - TextNotificationsManager.Debug(TranslationProvider.GetString(CheatUsed, arguments)); + var arguments = FluentBundle.Arguments("cheat", order.OrderString, "player", self.Owner.ResolvedPlayerName, "suffix", debugSuffix); + TextNotificationsManager.Debug(FluentProvider.GetString(CheatUsed, arguments)); } bool IUnlocksRenderPlayer.RenderPlayerUnlocked => Enabled; diff --git a/OpenRA.Mods.Common/Traits/Player/HarvesterAttackNotifier.cs b/OpenRA.Mods.Common/Traits/Player/HarvesterAttackNotifier.cs index 91e18ff96f..b52099344b 100644 --- a/OpenRA.Mods.Common/Traits/Player/HarvesterAttackNotifier.cs +++ b/OpenRA.Mods.Common/Traits/Player/HarvesterAttackNotifier.cs @@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification type to play.")] public readonly string Notification = "HarvesterAttack"; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display.")] public readonly string TextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Player/LobbyPrerequisiteCheckbox.cs b/OpenRA.Mods.Common/Traits/Player/LobbyPrerequisiteCheckbox.cs index 0094a3656e..2a0e4cecce 100644 --- a/OpenRA.Mods.Common/Traits/Player/LobbyPrerequisiteCheckbox.cs +++ b/OpenRA.Mods.Common/Traits/Player/LobbyPrerequisiteCheckbox.cs @@ -22,12 +22,12 @@ namespace OpenRA.Mods.Common.Traits [Desc("Internal id for this checkbox.")] public readonly string ID = null; - [TranslationReference] + [FluentReference] [FieldLoader.Require] [Desc("Display name for this checkbox.")] public readonly string Label = null; - [TranslationReference] + [FluentReference] [Desc("Description name for this checkbox.")] public readonly string Description = null; diff --git a/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs b/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs index 4cf94c0ea3..ffe0edacff 100644 --- a/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs +++ b/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs @@ -54,19 +54,19 @@ namespace OpenRA.Mods.Common.Traits [NotificationReference("Speech")] public readonly string WinNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string WinTextNotification = null; [NotificationReference("Speech")] public readonly string LoseNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string LoseTextNotification = null; [NotificationReference("Speech")] public readonly string LeaveNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string LeaveTextNotification = null; public override object Create(ActorInitializer init) { return new MissionObjectives(init.Self.Owner, this); } diff --git a/OpenRA.Mods.Common/Traits/Player/ModularBot.cs b/OpenRA.Mods.Common/Traits/Player/ModularBot.cs index e4af985ea4..e466716068 100644 --- a/OpenRA.Mods.Common/Traits/Player/ModularBot.cs +++ b/OpenRA.Mods.Common/Traits/Player/ModularBot.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Internal id for this bot.")] public readonly string Type = null; - [TranslationReference] + [FluentReference] [Desc("Human-readable name this bot uses.")] public readonly string Name = null; diff --git a/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs b/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs index 949d1c8c67..874d0f9b44 100644 --- a/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification to play after building placement if new construction options are available.")] public readonly string NewOptionsNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display after building placement if new construction options are available.")] public readonly string NewOptionsTextNotification = null; @@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification to play if building placement is not possible.")] public readonly string CannotPlaceNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display if building placement is not possible.")] public readonly string CannotPlaceTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Player/PlayerResources.cs b/OpenRA.Mods.Common/Traits/Player/PlayerResources.cs index 36ffbf6e7a..4e1017771b 100644 --- a/OpenRA.Mods.Common/Traits/Player/PlayerResources.cs +++ b/OpenRA.Mods.Common/Traits/Player/PlayerResources.cs @@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification to play when the player does not have any funds.")] public readonly string InsufficientFundsNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display when the player does not have any funds.")] public readonly string InsufficientFundsTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs index 6e44eae66d..46d080e2de 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs @@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits "The filename of the audio is defined per faction in notifications.yaml.")] public readonly string ReadyAudio = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Notification displayed when production is complete.")] public readonly string ReadyTextNotification = null; @@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits "The filename of the audio is defined per faction in notifications.yaml.")] public readonly string BlockedAudio = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Notification displayed when you can't train another actor", "when the build limit exceeded or the exit is jammed.")] public readonly string BlockedTextNotification = null; @@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits "The filename of the audio is defined per faction in notifications.yaml.")] public readonly string LimitedAudio = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Notification displayed when you can't queue another actor", "when the queue length limit is exceeded.")] public readonly string LimitedTextNotification = null; @@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits "The filename of the audio is defined per faction in notifications.yaml.")] public readonly string QueuedAudio = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Notification displayed when user clicks on the build palette icon.")] public readonly string QueuedTextNotification = null; @@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Traits "The filename of the audio is defined per faction in notifications.yaml.")] public readonly string OnHoldAudio = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Notification displayed when player right-clicks on the build palette icon.")] public readonly string OnHoldTextNotification = null; @@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Traits "The filename of the audio is defined per faction in notifications.yaml.")] public readonly string CancelledAudio = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Notification displayed when player right-clicks on a build palette icon that is already on hold.")] public readonly string CancelledTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Player/ProvidesTechPrerequisite.cs b/OpenRA.Mods.Common/Traits/Player/ProvidesTechPrerequisite.cs index bf98673ea7..60f8b26ee2 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProvidesTechPrerequisite.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProvidesTechPrerequisite.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Internal id for this tech level.")] public readonly string Id; - [TranslationReference] + [FluentReference] [Desc("Name shown in the lobby options.")] public readonly string Name; diff --git a/OpenRA.Mods.Common/Traits/Player/ResourceStorageWarning.cs b/OpenRA.Mods.Common/Traits/Player/ResourceStorageWarning.cs index dc7850a2c5..eb3fc060fd 100644 --- a/OpenRA.Mods.Common/Traits/Player/ResourceStorageWarning.cs +++ b/OpenRA.Mods.Common/Traits/Player/ResourceStorageWarning.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech to play for the warning.")] public readonly string Notification = "SilosNeeded"; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text to display for the warning.")] public readonly string TextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Player/StrategicVictoryConditions.cs b/OpenRA.Mods.Common/Traits/Player/StrategicVictoryConditions.cs index 06004f517b..9e7eb2bc2e 100644 --- a/OpenRA.Mods.Common/Traits/Player/StrategicVictoryConditions.cs +++ b/OpenRA.Mods.Common/Traits/Player/StrategicVictoryConditions.cs @@ -46,10 +46,10 @@ namespace OpenRA.Mods.Common.Traits public class StrategicVictoryConditions : ITick, ISync, INotifyWinStateChanged, INotifyTimeLimit { - [TranslationReference("player")] + [FluentReference("player")] const string PlayerIsVictorious = "notification-player-is-victorious"; - [TranslationReference("player")] + [FluentReference("player")] const string PlayerIsDefeated = "notification-player-is-defeated"; readonly StrategicVictoryConditionsInfo info; @@ -151,7 +151,7 @@ namespace OpenRA.Mods.Common.Traits if (info.SuppressNotifications) return; - TextNotificationsManager.AddSystemLine(PlayerIsDefeated, Translation.Arguments("player", player.ResolvedPlayerName)); + TextNotificationsManager.AddSystemLine(PlayerIsDefeated, FluentBundle.Arguments("player", player.ResolvedPlayerName)); Game.RunAfterDelay(info.NotificationDelay, () => { if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer) @@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.Traits if (info.SuppressNotifications) return; - TextNotificationsManager.AddSystemLine(PlayerIsVictorious, Translation.Arguments("player", player.ResolvedPlayerName)); + TextNotificationsManager.AddSystemLine(PlayerIsVictorious, FluentBundle.Arguments("player", player.ResolvedPlayerName)); Game.RunAfterDelay(info.NotificationDelay, () => { if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer) diff --git a/OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs b/OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs index cebd4d3227..1cb89f5094 100644 --- a/OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs +++ b/OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string SpeechNotification = null; [Desc("The text notification to display when the player is low power.")] - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string TextNotification = null; public override object Create(ActorInitializer init) { return new PowerManager(init.Self, this); } diff --git a/OpenRA.Mods.Common/Traits/ProductionParadrop.cs b/OpenRA.Mods.Common/Traits/ProductionParadrop.cs index 92b1a456f7..b8584564f0 100644 --- a/OpenRA.Mods.Common/Traits/ProductionParadrop.cs +++ b/OpenRA.Mods.Common/Traits/ProductionParadrop.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification to play when dropping the unit.")] public readonly string ReadyAudio = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display when dropping the unit.")] public readonly string ReadyTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Render/CustomTerrainDebugOverlay.cs b/OpenRA.Mods.Common/Traits/Render/CustomTerrainDebugOverlay.cs index 6f8272da44..022b87314a 100644 --- a/OpenRA.Mods.Common/Traits/Render/CustomTerrainDebugOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/CustomTerrainDebugOverlay.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits { const string CommandName = "custom-terrain"; - [TranslationReference] + [FluentReference] const string CommandDescription = "description-custom-terrain-debug-overlay"; public bool Enabled; diff --git a/OpenRA.Mods.Common/Traits/RepairsBridges.cs b/OpenRA.Mods.Common/Traits/RepairsBridges.cs index 3528b0e2f5..9d66a229e6 100644 --- a/OpenRA.Mods.Common/Traits/RepairsBridges.cs +++ b/OpenRA.Mods.Common/Traits/RepairsBridges.cs @@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification to play when a bridge is repaired.")] public readonly string RepairNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display when a bridge is repaired.")] public readonly string RepairTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/RepairsUnits.cs b/OpenRA.Mods.Common/Traits/RepairsUnits.cs index e61aff7f9b..9644d39139 100644 --- a/OpenRA.Mods.Common/Traits/RepairsUnits.cs +++ b/OpenRA.Mods.Common/Traits/RepairsUnits.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification played when starting to repair a unit.")] public readonly string StartRepairingNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification displayed when starting to repair a unit.")] public readonly string StartRepairingTextNotification = null; @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification played when repairing a unit is done.")] public readonly string FinishRepairingNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification displayed when repairing a unit is done.")] public readonly string FinishRepairingTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Sellable.cs b/OpenRA.Mods.Common/Traits/Sellable.cs index 0689fc4041..bdc9edce72 100644 --- a/OpenRA.Mods.Common/Traits/Sellable.cs +++ b/OpenRA.Mods.Common/Traits/Sellable.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification to play.")] public readonly string Notification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display.")] public readonly string TextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Sound/ActorLostNotification.cs b/OpenRA.Mods.Common/Traits/Sound/ActorLostNotification.cs index 446c3aa5ad..c14e133050 100644 --- a/OpenRA.Mods.Common/Traits/Sound/ActorLostNotification.cs +++ b/OpenRA.Mods.Common/Traits/Sound/ActorLostNotification.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits.Sound public readonly string Notification = "UnitLost"; [Desc("Text notification to display.")] - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string TextNotification = null; public readonly bool NotifyAll = false; diff --git a/OpenRA.Mods.Common/Traits/Sound/AnnounceOnSeen.cs b/OpenRA.Mods.Common/Traits/Sound/AnnounceOnSeen.cs index ec1542c35e..60d4599eff 100644 --- a/OpenRA.Mods.Common/Traits/Sound/AnnounceOnSeen.cs +++ b/OpenRA.Mods.Common/Traits/Sound/AnnounceOnSeen.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits.Sound [Desc("Speech notification to play.")] public readonly string Notification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display.")] public readonly string TextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs b/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs index b5b7204fc3..2789b451a2 100644 --- a/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs +++ b/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits.Sound [Desc("Speech notification to play to the new owner.")] public readonly string Notification = "BuildingCaptured"; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display to the new owner.")] public readonly string TextNotification = null; @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits.Sound [Desc("Speech notification to play to the old owner.")] public readonly string LoseNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display to the old owner.")] public readonly string LoseTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs index 76a30d82b3..83278b7646 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification to play when entering the drop zone.")] public readonly string ReinforcementsArrivedSpeechNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display when entering the drop zone.")] public readonly string ReinforcementsArrivedTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/ProduceActorPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/ProduceActorPower.cs index 1ee55900e2..8ea63b9bc0 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/ProduceActorPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/ProduceActorPower.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits "The filename of the audio is defined per faction in notifications.yaml.")] public readonly string ReadyAudio = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification displayed when production is activated.")] public readonly string ReadyTextNotification = null; @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits "The filename of the audio is defined per faction in notifications.yaml.")] public readonly string BlockedAudio = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification displayed when the exit is jammed.")] public readonly string BlockedTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs index bc17fdec01..6eabeb150e 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs @@ -30,10 +30,10 @@ namespace OpenRA.Mods.Common.Traits [Desc("Palette used for the icon.")] public readonly string IconPalette = "chrome"; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string Name = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string Description = null; [Desc("Allow multiple instances of the same support power.")] @@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits [NotificationReference("Speech")] public readonly string DetectedSpeechNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string DetectedTextNotification = null; public readonly string BeginChargeSound = null; @@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits [NotificationReference("Speech")] public readonly string BeginChargeSpeechNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string BeginChargeTextNotification = null; public readonly string EndChargeSound = null; @@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits [NotificationReference("Speech")] public readonly string EndChargeSpeechNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string EndChargeTextNotification = null; public readonly string SelectTargetSound = null; @@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits [NotificationReference("Speech")] public readonly string SelectTargetSpeechNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string SelectTargetTextNotification = null; public readonly string InsufficientPowerSound = null; @@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Traits [NotificationReference("Speech")] public readonly string InsufficientPowerSpeechNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string InsufficientPowerTextNotification = null; public readonly string LaunchSound = null; @@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits [NotificationReference("Speech")] public readonly string LaunchSpeechNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string LaunchTextNotification = null; public readonly string IncomingSound = null; @@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.Traits [NotificationReference("Speech")] public readonly string IncomingSpeechNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string IncomingTextNotification = null; [Desc("Defines to which players the timer is shown.")] diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs index 2ee754ebd9..c6f248e19a 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs @@ -177,8 +177,8 @@ namespace OpenRA.Mods.Common.Traits Key = key; TotalTicks = info.ChargeInterval; remainingSubTicks = info.StartFullyCharged ? 0 : TotalTicks * 100; - Name = info.Name == null ? string.Empty : TranslationProvider.GetString(info.Name); - Description = info.Description == null ? string.Empty : TranslationProvider.GetString(info.Description); + Name = info.Name == null ? string.Empty : FluentProvider.GetString(info.Name); + Description = info.Description == null ? string.Empty : FluentProvider.GetString(info.Description); Manager = manager; } diff --git a/OpenRA.Mods.Common/Traits/Tooltip.cs b/OpenRA.Mods.Common/Traits/Tooltip.cs index dd4fb18eac..cbf8029753 100644 --- a/OpenRA.Mods.Common/Traits/Tooltip.cs +++ b/OpenRA.Mods.Common/Traits/Tooltip.cs @@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits public abstract class TooltipInfoBase : ConditionalTraitInfo, Requires { [FieldLoader.Require] - [TranslationReference] + [FluentReference] public readonly string Name; } @@ -31,22 +31,22 @@ namespace OpenRA.Mods.Common.Traits { [Desc("An optional generic name (i.e. \"Soldier\" or \"Structure\")" + "to be shown to chosen players.")] - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string GenericName; [Desc("Prefix generic tooltip name with 'Ally/Neutral/EnemyPrefix'.")] public readonly bool GenericStancePrefix = true; [Desc("Prefix to display in the tooltip for allied units.")] - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string AllyPrefix = "label-tooltip-prefix.ally"; [Desc("Prefix to display in the tooltip for neutral units.")] - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string NeutralPrefix; [Desc("Prefix to display in the tooltip for enemy units.")] - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string EnemyPrefix = "label-tooltip-prefix.enemy"; [Desc("Player stances that the generic name should be shown to.")] @@ -60,19 +60,19 @@ namespace OpenRA.Mods.Common.Traits public string TooltipForPlayerStance(PlayerRelationship relationship) { if (relationship == PlayerRelationship.None || !GenericVisibility.HasRelationship(relationship)) - return TranslationProvider.GetString(Name); + return FluentProvider.GetString(Name); - var genericName = string.IsNullOrEmpty(GenericName) ? "" : TranslationProvider.GetString(GenericName); + var genericName = string.IsNullOrEmpty(GenericName) ? "" : FluentProvider.GetString(GenericName); if (GenericStancePrefix) { if (!string.IsNullOrEmpty(AllyPrefix) && relationship == PlayerRelationship.Ally) - return TranslationProvider.GetString(AllyPrefix) + " " + genericName; + return FluentProvider.GetString(AllyPrefix) + " " + genericName; if (!string.IsNullOrEmpty(NeutralPrefix) && relationship == PlayerRelationship.Neutral) - return TranslationProvider.GetString(NeutralPrefix) + " " + genericName; + return FluentProvider.GetString(NeutralPrefix) + " " + genericName; if (!string.IsNullOrEmpty(EnemyPrefix) && relationship == PlayerRelationship.Enemy) - return TranslationProvider.GetString(EnemyPrefix) + " " + genericName; + return FluentProvider.GetString(EnemyPrefix) + " " + genericName; } return genericName; diff --git a/OpenRA.Mods.Common/Traits/TooltipDescription.cs b/OpenRA.Mods.Common/Traits/TooltipDescription.cs index ae0d639e10..eec7802730 100644 --- a/OpenRA.Mods.Common/Traits/TooltipDescription.cs +++ b/OpenRA.Mods.Common/Traits/TooltipDescription.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits public class TooltipDescriptionInfo : ConditionalTraitInfo { [FieldLoader.Require] - [TranslationReference] + [FluentReference] [Desc("Text shown in tooltip.")] public readonly string Description; @@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits : base(info) { this.self = self; - TooltipText = TranslationProvider.GetString(info.Description); + TooltipText = FluentProvider.GetString(info.Description); } public bool IsTooltipVisible(Player forPlayer) diff --git a/OpenRA.Mods.Common/Traits/Transforms.cs b/OpenRA.Mods.Common/Traits/Transforms.cs index f96ee6be5a..888cd096b6 100644 --- a/OpenRA.Mods.Common/Traits/Transforms.cs +++ b/OpenRA.Mods.Common/Traits/Transforms.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification to play when transforming.")] public readonly string TransformNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display when transforming.")] public readonly string TransformTextNotification = null; @@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Speech notification to play when the transformation is blocked.")] public readonly string NoTransformNotification = null; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] [Desc("Text notification to display when the transformation is blocked.")] public readonly string NoTransformTextNotification = null; diff --git a/OpenRA.Mods.Common/Traits/World/CellTriggerOverlay.cs b/OpenRA.Mods.Common/Traits/World/CellTriggerOverlay.cs index 5b217fb3cb..8d16dbd66d 100644 --- a/OpenRA.Mods.Common/Traits/World/CellTriggerOverlay.cs +++ b/OpenRA.Mods.Common/Traits/World/CellTriggerOverlay.cs @@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits { const string CommandName = "triggers"; - [TranslationReference] + [FluentReference] const string CommandDescription = "description-cell-triggers-overlay"; bool enabled; diff --git a/OpenRA.Mods.Common/Traits/World/ColorPickerManager.cs b/OpenRA.Mods.Common/Traits/World/ColorPickerManager.cs index ee2568b3c4..c50a063421 100644 --- a/OpenRA.Mods.Common/Traits/World/ColorPickerManager.cs +++ b/OpenRA.Mods.Common/Traits/World/ColorPickerManager.cs @@ -24,13 +24,13 @@ namespace OpenRA.Mods.Common.Traits [Desc("Configuration options for the lobby player color picker. Attach this to the world actor.")] public class ColorPickerManagerInfo : TraitInfo, IColorPickerManagerInfo { - [TranslationReference] + [FluentReference] const string PlayerColorTerrain = "notification-player-color-terrain"; - [TranslationReference] + [FluentReference] const string PlayerColorPlayer = "notification-player-color-player"; - [TranslationReference] + [FluentReference] const string InvalidPlayerColor = "notification-invalid-player-color"; [Desc("Minimum and maximum saturation levels that are valid for use.")] diff --git a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs index 4afbf47380..070457ce53 100644 --- a/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs +++ b/OpenRA.Mods.Common/Traits/World/CrateSpawner.cs @@ -21,11 +21,11 @@ namespace OpenRA.Mods.Common.Traits [TraitLocation(SystemActors.World)] public class CrateSpawnerInfo : TraitInfo, ILobbyOptions { - [TranslationReference] + [FluentReference] [Desc("Descriptive label for the crates checkbox in the lobby.")] public readonly string CheckboxLabel = "checkbox-crates.label"; - [TranslationReference] + [FluentReference] [Desc("Tooltip description for the crates checkbox in the lobby.")] public readonly string CheckboxDescription = "checkbox-crates.description"; diff --git a/OpenRA.Mods.Common/Traits/World/EditorActionManager.cs b/OpenRA.Mods.Common/Traits/World/EditorActionManager.cs index 986b03e76d..9052b48ff3 100644 --- a/OpenRA.Mods.Common/Traits/World/EditorActionManager.cs +++ b/OpenRA.Mods.Common/Traits/World/EditorActionManager.cs @@ -146,12 +146,12 @@ namespace OpenRA.Mods.Common.Traits sealed class OpenMapAction : IEditorAction { - [TranslationReference] + [FluentReference] const string Opened = "notification-opened"; public OpenMapAction() { - Text = TranslationProvider.GetString(Opened); + Text = FluentProvider.GetString(Opened); } public void Execute() diff --git a/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs b/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs index fcef483161..56c565c68d 100644 --- a/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs +++ b/OpenRA.Mods.Common/Traits/World/EditorActorPreview.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits public readonly ActorInfo Info; public string Tooltip => - (tooltip == null ? " < " + Info.Name + " >" : TranslationProvider.GetString(tooltip.Name)) + "\n" + Owner.Name + " (" + Owner.Faction + ")" + (tooltip == null ? " < " + Info.Name + " >" : FluentProvider.GetString(tooltip.Name)) + "\n" + Owner.Name + " (" + Owner.Faction + ")" + "\nID: " + ID + "\nType: " + Info.Name; public string Type => reference.Type; diff --git a/OpenRA.Mods.Common/Traits/World/ExitsDebugOverlayManager.cs b/OpenRA.Mods.Common/Traits/World/ExitsDebugOverlayManager.cs index eea249c47b..2a3faa2627 100644 --- a/OpenRA.Mods.Common/Traits/World/ExitsDebugOverlayManager.cs +++ b/OpenRA.Mods.Common/Traits/World/ExitsDebugOverlayManager.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits { const string CommandName = "exits-overlay"; - [TranslationReference] + [FluentReference] const string CommandDescription = "description-exits-overlay"; public readonly SpriteFont Font; diff --git a/OpenRA.Mods.Common/Traits/World/HierarchicalPathFinderOverlay.cs b/OpenRA.Mods.Common/Traits/World/HierarchicalPathFinderOverlay.cs index e58e77aae7..013bda56ee 100644 --- a/OpenRA.Mods.Common/Traits/World/HierarchicalPathFinderOverlay.cs +++ b/OpenRA.Mods.Common/Traits/World/HierarchicalPathFinderOverlay.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits { const string CommandName = "hpf"; - [TranslationReference] + [FluentReference] const string CommandDescription = "description-hpf-debug-overlay"; readonly HierarchicalPathFinderOverlayInfo info; diff --git a/OpenRA.Mods.Common/Traits/World/MapBuildRadius.cs b/OpenRA.Mods.Common/Traits/World/MapBuildRadius.cs index 217ecce612..a4b254ff21 100644 --- a/OpenRA.Mods.Common/Traits/World/MapBuildRadius.cs +++ b/OpenRA.Mods.Common/Traits/World/MapBuildRadius.cs @@ -18,11 +18,11 @@ namespace OpenRA.Mods.Common.Traits [Desc("Controls the build radius checkboxes in the lobby options.")] public class MapBuildRadiusInfo : TraitInfo, ILobbyOptions { - [TranslationReference] + [FluentReference] [Desc("Descriptive label for the ally build radius checkbox in the lobby.")] public readonly string AllyBuildRadiusCheckboxLabel = "checkbox-ally-build-radius.label"; - [TranslationReference] + [FluentReference] [Desc("Tooltip description for the ally build radius checkbox in the lobby.")] public readonly string AllyBuildRadiusCheckboxDescription = "checkbox-ally-build-radius.description"; @@ -38,11 +38,11 @@ namespace OpenRA.Mods.Common.Traits [Desc("Display order for the ally build radius checkbox in the lobby.")] public readonly int AllyBuildRadiusCheckboxDisplayOrder = 0; - [TranslationReference] + [FluentReference] [Desc("Tooltip description for the build radius checkbox in the lobby.")] public readonly string BuildRadiusCheckboxLabel = "checkbox-build-radius.label"; - [TranslationReference] + [FluentReference] [Desc("Tooltip description for the build radius checkbox in the lobby.")] public readonly string BuildRadiusCheckboxDescription = "checkbox-build-radius.description"; diff --git a/OpenRA.Mods.Common/Traits/World/MapCreeps.cs b/OpenRA.Mods.Common/Traits/World/MapCreeps.cs index 68a5692d0b..b0a64cfe71 100644 --- a/OpenRA.Mods.Common/Traits/World/MapCreeps.cs +++ b/OpenRA.Mods.Common/Traits/World/MapCreeps.cs @@ -18,11 +18,11 @@ namespace OpenRA.Mods.Common.Traits [TraitLocation(SystemActors.World)] public class MapCreepsInfo : TraitInfo, ILobbyOptions { - [TranslationReference] + [FluentReference] [Desc("Descriptive label for the creeps checkbox in the lobby.")] public readonly string CheckboxLabel = "dropdown-map-creeps.label"; - [TranslationReference] + [FluentReference] [Desc("Tooltip description for the creeps checkbox in the lobby.")] public readonly string CheckboxDescription = "dropdown-map-creeps.description"; diff --git a/OpenRA.Mods.Common/Traits/World/MapOptions.cs b/OpenRA.Mods.Common/Traits/World/MapOptions.cs index 88dcbec94d..962c732d78 100644 --- a/OpenRA.Mods.Common/Traits/World/MapOptions.cs +++ b/OpenRA.Mods.Common/Traits/World/MapOptions.cs @@ -19,11 +19,11 @@ namespace OpenRA.Mods.Common.Traits [Desc("Controls the game speed, tech level, and short game lobby options.")] public class MapOptionsInfo : TraitInfo, ILobbyOptions, IRulesetLoaded { - [TranslationReference] + [FluentReference] [Desc("Descriptive label for the short game checkbox in the lobby.")] public readonly string ShortGameCheckboxLabel = "checkbox-short-game.label"; - [TranslationReference] + [FluentReference] [Desc("Tooltip description for the short game checkbox in the lobby.")] public readonly string ShortGameCheckboxDescription = "checkbox-short-game.description"; @@ -39,11 +39,11 @@ namespace OpenRA.Mods.Common.Traits [Desc("Display order for the short game checkbox in the lobby.")] public readonly int ShortGameCheckboxDisplayOrder = 0; - [TranslationReference] + [FluentReference] [Desc("Descriptive label for the tech level option in the lobby.")] public readonly string TechLevelDropdownLabel = "dropdown-tech-level.label"; - [TranslationReference] + [FluentReference] [Desc("Tooltip description for the tech level option in the lobby.")] public readonly string TechLevelDropdownDescription = "dropdown-tech-level.description"; @@ -59,11 +59,11 @@ namespace OpenRA.Mods.Common.Traits [Desc("Display order for the tech level option in the lobby.")] public readonly int TechLevelDropdownDisplayOrder = 0; - [TranslationReference] + [FluentReference] [Desc("Tooltip description for the game speed option in the lobby.")] public readonly string GameSpeedDropdownLabel = "dropdown-game-speed.label"; - [TranslationReference] + [FluentReference] [Desc("Description of the game speed option in the lobby.")] public readonly string GameSpeedDropdownDescription = "dropdown-game-speed.description"; @@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits techLevels, TechLevel, TechLevelDropdownLocked); var gameSpeeds = Game.ModData.Manifest.Get(); - var speeds = gameSpeeds.Speeds.ToDictionary(s => s.Key, s => TranslationProvider.GetString(s.Value.Name)); + var speeds = gameSpeeds.Speeds.ToDictionary(s => s.Key, s => FluentProvider.GetString(s.Value.Name)); // NOTE: This is just exposing the UI, the backend logic for this option is hardcoded in World. yield return new LobbyOption(map, "gamespeed", diff --git a/OpenRA.Mods.Common/Traits/World/MapStartingLocations.cs b/OpenRA.Mods.Common/Traits/World/MapStartingLocations.cs index 69797a2c50..3492bda0e3 100644 --- a/OpenRA.Mods.Common/Traits/World/MapStartingLocations.cs +++ b/OpenRA.Mods.Common/Traits/World/MapStartingLocations.cs @@ -25,11 +25,11 @@ namespace OpenRA.Mods.Common.Traits { public readonly WDist InitialExploreRange = WDist.FromCells(5); - [TranslationReference] + [FluentReference] [Desc("Descriptive label for the spawn positions checkbox in the lobby.")] public readonly string SeparateTeamSpawnsCheckboxLabel = "checkbox-separate-team-spawns.label"; - [TranslationReference] + [FluentReference] [Desc("Tooltip description for the spawn positions checkbox in the lobby.")] public readonly string SeparateTeamSpawnsCheckboxDescription = "checkbox-separate-team-spawns.description"; diff --git a/OpenRA.Mods.Common/Traits/World/MapStartingUnits.cs b/OpenRA.Mods.Common/Traits/World/MapStartingUnits.cs index 8682de6e92..5303087b0a 100644 --- a/OpenRA.Mods.Common/Traits/World/MapStartingUnits.cs +++ b/OpenRA.Mods.Common/Traits/World/MapStartingUnits.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Internal class ID.")] public readonly string Class = "none"; - [TranslationReference] + [FluentReference] [Desc("Exposed via the UI to the player.")] public readonly string ClassName = "Unlabeled"; diff --git a/OpenRA.Mods.Common/Traits/World/PathFinderOverlay.cs b/OpenRA.Mods.Common/Traits/World/PathFinderOverlay.cs index 86d24aed76..6b81138963 100644 --- a/OpenRA.Mods.Common/Traits/World/PathFinderOverlay.cs +++ b/OpenRA.Mods.Common/Traits/World/PathFinderOverlay.cs @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits { const string CommandName = "path-debug"; - [TranslationReference] + [FluentReference] const string CommandDescription = "description-path-debug-overlay"; sealed class Record : PathSearch.IRecorder, IEnumerable<(CPos Source, CPos Destination, int CostSoFar, int EstimatedRemainingCost)> diff --git a/OpenRA.Mods.Common/Traits/World/ResourceRenderer.cs b/OpenRA.Mods.Common/Traits/World/ResourceRenderer.cs index 39b45a8e22..a80f8d6a46 100644 --- a/OpenRA.Mods.Common/Traits/World/ResourceRenderer.cs +++ b/OpenRA.Mods.Common/Traits/World/ResourceRenderer.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits [FieldLoader.Require] [Desc("Resource name used by tooltips.")] - [TranslationReference] + [FluentReference] public readonly string Name = null; public ResourceTypeInfo(MiniYaml yaml) @@ -273,7 +273,7 @@ namespace OpenRA.Mods.Common.Traits if (info == null) return null; - return TranslationProvider.GetString(info.Name); + return FluentProvider.GetString(info.Name); } IEnumerable IResourceRenderer.ResourceTypes => Info.ResourceTypes.Keys; diff --git a/OpenRA.Mods.Common/Traits/World/ScriptLobbyDropdown.cs b/OpenRA.Mods.Common/Traits/World/ScriptLobbyDropdown.cs index 026c00e47c..8a348a93cc 100644 --- a/OpenRA.Mods.Common/Traits/World/ScriptLobbyDropdown.cs +++ b/OpenRA.Mods.Common/Traits/World/ScriptLobbyDropdown.cs @@ -23,11 +23,11 @@ namespace OpenRA.Mods.Common.Traits public readonly string ID = null; [FieldLoader.Require] - [TranslationReference] + [FluentReference] [Desc("Descriptive label for this option.")] public readonly string Label = null; - [TranslationReference] + [FluentReference] [Desc("Tooltip description for this option.")] public readonly string Description = null; @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string Default = null; [FieldLoader.Require] - [TranslationReference(dictionaryReference: LintDictionaryReference.Values)] + [FluentReference(dictionaryReference: LintDictionaryReference.Values)] [Desc("Options to choose from.")] public readonly Dictionary Values = null; diff --git a/OpenRA.Mods.Common/Traits/World/SpawnStartingUnits.cs b/OpenRA.Mods.Common/Traits/World/SpawnStartingUnits.cs index 8418de7ce9..56861e3128 100644 --- a/OpenRA.Mods.Common/Traits/World/SpawnStartingUnits.cs +++ b/OpenRA.Mods.Common/Traits/World/SpawnStartingUnits.cs @@ -25,11 +25,11 @@ namespace OpenRA.Mods.Common.Traits { public readonly string StartingUnitsClass = "none"; - [TranslationReference] + [FluentReference] [Desc("Descriptive label for the starting units option in the lobby.")] public readonly string DropdownLabel = "dropdown-starting-units.label"; - [TranslationReference] + [FluentReference] [Desc("Tooltip description for the starting units option in the lobby.")] public readonly string DropdownDescription = "dropdown-starting-units.description"; diff --git a/OpenRA.Mods.Common/Traits/World/StartGameNotification.cs b/OpenRA.Mods.Common/Traits/World/StartGameNotification.cs index 8437892a53..7272f8eda4 100644 --- a/OpenRA.Mods.Common/Traits/World/StartGameNotification.cs +++ b/OpenRA.Mods.Common/Traits/World/StartGameNotification.cs @@ -20,19 +20,19 @@ namespace OpenRA.Mods.Common.Traits [NotificationReference("Speech")] public readonly string Notification = "StartGame"; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string TextNotification = null; [NotificationReference("Speech")] public readonly string LoadedNotification = "GameLoaded"; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string LoadedTextNotification = null; [NotificationReference("Speech")] public readonly string SavedNotification = "GameSaved"; - [TranslationReference(optional: true)] + [FluentReference(optional: true)] public readonly string SavedTextNotification = null; public override object Create(ActorInitializer init) { return new StartGameNotification(this); } diff --git a/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs b/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs index 738e423225..61b8759438 100644 --- a/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs +++ b/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits { const string CommandName = "terrain-geometry"; - [TranslationReference] + [FluentReference] const string CommandDescription = "description-terrain-geometry-overlay"; public bool Enabled; diff --git a/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs b/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs index b1331a1a5d..98c1190513 100644 --- a/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs +++ b/OpenRA.Mods.Common/Traits/World/TimeLimitManager.cs @@ -22,11 +22,11 @@ namespace OpenRA.Mods.Common.Traits [Desc("This trait allows setting a time limit on matches. Attach this to the World actor.")] public class TimeLimitManagerInfo : TraitInfo, ILobbyOptions, IRulesetLoaded { - [TranslationReference] + [FluentReference] [Desc("Label that will be shown for the time limit option in the lobby.")] public readonly string TimeLimitLabel = "dropdown-time-limit.label"; - [TranslationReference] + [FluentReference] [Desc("Tooltip description that will be shown for the time limit option in the lobby.")] public readonly string TimeLimitDescription = "dropdown-time-limit.description"; @@ -77,10 +77,10 @@ namespace OpenRA.Mods.Common.Traits throw new YamlException("TimeLimitDefault must be a value from TimeLimitOptions"); } - [TranslationReference] + [FluentReference] const string NoTimeLimit = "options-time-limit.no-limit"; - [TranslationReference("minutes")] + [FluentReference("minutes")] const string TimeLimitOption = "options-time-limit.options"; IEnumerable ILobbyOptions.LobbyOptions(MapPreview map) @@ -88,9 +88,9 @@ namespace OpenRA.Mods.Common.Traits var timelimits = TimeLimitOptions.ToDictionary(m => m.ToStringInvariant(), m => { if (m == 0) - return TranslationProvider.GetString(NoTimeLimit); + return FluentProvider.GetString(NoTimeLimit); else - return TranslationProvider.GetString(TimeLimitOption, Translation.Arguments("minutes", m)); + return FluentProvider.GetString(TimeLimitOption, FluentBundle.Arguments("minutes", m)); }); yield return new LobbyOption(map, "timelimit", TimeLimitLabel, TimeLimitDescription, TimeLimitDropdownVisible, TimeLimitDisplayOrder, @@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Traits public class TimeLimitManager : INotifyTimeLimit, ITick, IWorldLoaded { - [TranslationReference] + [FluentReference] const string TimeLimitExpired = "notification-time-limit-expired"; readonly TimeLimitManagerInfo info; @@ -182,7 +182,7 @@ namespace OpenRA.Mods.Common.Traits countdownLabel.GetText = () => null; if (!info.SkipTimerExpiredNotification) - TextNotificationsManager.AddSystemLine(TranslationProvider.GetString(TimeLimitExpired)); + TextNotificationsManager.AddSystemLine(FluentProvider.GetString(TimeLimitExpired)); } } } diff --git a/OpenRA.Mods.Common/UpdateRules/UpdateUtils.cs b/OpenRA.Mods.Common/UpdateRules/UpdateUtils.cs index 0cbfc25d0e..4aa5b20204 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdateUtils.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdateUtils.cs @@ -334,11 +334,11 @@ namespace OpenRA.Mods.Common.UpdateRules return string.Join("\n", messages.Select(m => prefix + $" {separator} {m.Replace("\n", "\n " + prefix)}")); } - public static bool IsAlreadyTranslated(string translation) + public static bool IsAlreadyExtracted(string key) { - if (translation == translation.ToLowerInvariant() && translation.Any(c => c == '-') && translation.All(c => c != ' ')) + if (key == key.ToLowerInvariant() && key.Any(c => c == '-') && key.All(c => c != ' ')) { - Console.WriteLine($"Skipping {translation} because it is already translated."); + Console.WriteLine($"Skipping {key} because it is already extracted."); return true; } diff --git a/OpenRA.Mods.Common/UtilityCommands/ExtractChromeStrings.cs b/OpenRA.Mods.Common/UtilityCommands/ExtractChromeStrings.cs index 5431033e46..620286e73c 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ExtractChromeStrings.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ExtractChromeStrings.cs @@ -11,7 +11,6 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.IO; using System.Linq; using OpenRA.FileSystem; @@ -37,11 +36,11 @@ namespace OpenRA.Mods.Common.UtilityCommands // HACK: The engine code assumes that Game.modData is set. var modData = Game.ModData = utility.ModData; - var translatableFields = modData.ObjectCreator.GetTypes() + var widgetInfos = modData.ObjectCreator.GetTypes() .Where(t => t.Name.EndsWith("Widget", StringComparison.InvariantCulture) && t.IsSubclassOf(typeof(Widget))) .ToDictionary( t => t.Name[..^6], - t => t.GetFields().Where(f => f.HasAttribute()).Select(f => f.Name).ToArray()) + t => t.GetFields().Where(f => f.HasAttribute()).Select(f => f.Name).ToArray()) .Where(t => t.Value.Length > 0) .ToDictionary(t => t.Key, t => t.Value); @@ -53,12 +52,12 @@ namespace OpenRA.Mods.Common.UtilityCommands var fluentPackage = modData.ModFiles.OpenPackage(fluentFolder); var fluentPath = Path.Combine(fluentPackage.Name, "chrome/en.ftl"); - var unsortedCandidates = new List(); - var groupedCandidates = new Dictionary, List>(); + var unsortedCandidates = new List(); + var groupedCandidates = new Dictionary, List>(); var yamlSet = new YamlFileSet(); - // Get all translations. + // Get all string candidates. foreach (var chrome in layout) { modData.ModFiles.TryGetPackageContaining(chrome, out var chromePackage, out var chromeName); @@ -67,40 +66,40 @@ namespace OpenRA.Mods.Common.UtilityCommands var yaml = MiniYaml.FromFile(chromePath, false).ConvertAll(n => new MiniYamlNodeBuilder(n)); yamlSet.Add(((IReadWritePackage)chromePackage, chromeName, yaml)); - var translationCandidates = new List(); + var extractionCandidates = new List(); foreach (var node in yaml) { if (node.Key != null) { var nodeSplit = node.Key.Split('@'); var nodeId = nodeSplit.Length > 1 ? ClearContainersAndToLower(nodeSplit[1]) : null; - FromChromeLayout(node, translatableFields, nodeId, ref translationCandidates); + FromChromeLayout(node, widgetInfos, nodeId, ref extractionCandidates); } } - if (translationCandidates.Count > 0) + if (extractionCandidates.Count > 0) { var chromeFilename = chrome.Split('/').Last(); - groupedCandidates[new HashSet() { chromeFilename }] = new List(); - for (var i = 0; i < translationCandidates.Count; i++) + groupedCandidates[new HashSet() { chromeFilename }] = new List(); + for (var i = 0; i < extractionCandidates.Count; i++) { - var candidate = translationCandidates[i]; + var candidate = extractionCandidates[i]; candidate.Chrome = chromeFilename; unsortedCandidates.Add(candidate); } } } - // Join matching translations. + // Join matching candidates. foreach (var candidate in unsortedCandidates) { HashSet foundHash = null; - TranslationCandidate found = default; - foreach (var (hash, translation) in groupedCandidates) + ExtractionCandidate found = default; + foreach (var (hash, candidates) in groupedCandidates) { - foreach (var c in translation) + foreach (var c in candidates) { - if (c.Key == candidate.Key && c.Type == candidate.Type && c.Translation == candidate.Translation) + if (c.Key == candidate.Key && c.Type == candidate.Type && c.Value == candidate.Value) { foundHash = hash; found = c; @@ -127,7 +126,7 @@ namespace OpenRA.Mods.Common.UtilityCommands if (nHash.Key != null) groupedCandidates[nHash.Key].Add(candidate); else - groupedCandidates[newHash] = new List() { candidate }; + groupedCandidates[newHash] = new List() { candidate }; } var startWithNewline = File.Exists(fluentPath); @@ -136,7 +135,7 @@ namespace OpenRA.Mods.Common.UtilityCommands if (!startWithNewline) Directory.CreateDirectory(Path.GetDirectoryName(fluentPath)); - // Write to translation files. + // Write output .ftl files. using (var fluentWriter = new StreamWriter(fluentPath, append: true)) { foreach (var (chromeFilename, candidates) in groupedCandidates.OrderBy(t => string.Join(',', t.Key))) @@ -151,30 +150,28 @@ namespace OpenRA.Mods.Common.UtilityCommands fluentWriter.WriteLine("## " + string.Join(", ", chromeFilename)); - // Pushing blocks of translations to string first allows for fancier formatting. + // Pushing blocks to string first allows for fancier formatting. var build = ""; foreach (var grouping in candidates.GroupBy(t => t.Key)) { if (grouping.Count() == 1) { var candidate = grouping.First(); - var translationKey = candidate.Key; - if (candidate.Type == "text") - translationKey = $"{translationKey}"; - else - translationKey = $"{translationKey}-" + candidate.Type.Replace("text", ""); + var key = candidate.Key; + if (candidate.Type != "text") + key = $"{key}-" + candidate.Type.Replace("text", ""); - build += $"{translationKey} = {candidate.Translation}\n"; + build += $"{key} = {candidate.Value}\n"; foreach (var node in candidate.Nodes) - node.Value.Value = translationKey; + node.Value.Value = key; } else { if (build.Length > 1 && build.Substring(build.Length - 2, 2) != "\n\n") build += "\n"; - var translationKey = grouping.Key; - build += $"{translationKey} =\n"; + var key = grouping.Key; + build += $"{key} =\n"; foreach (var candidate in grouping) { var type = candidate.Type; @@ -186,9 +183,9 @@ namespace OpenRA.Mods.Common.UtilityCommands type = type.Replace("text", ""); } - build += $" .{type} = {candidate.Translation}\n"; + build += $" .{type} = {candidate.Value}\n"; foreach (var node in candidate.Nodes) - node.Value.Value = $"{translationKey}.{type}"; + node.Value.Value = $"{key}.{type}"; } build += "\n"; @@ -203,20 +200,20 @@ namespace OpenRA.Mods.Common.UtilityCommands } } - struct TranslationCandidate + struct ExtractionCandidate { public string Chrome; public readonly string Key; public readonly string Type; - public readonly string Translation; + public readonly string Value; public readonly List Nodes; - public TranslationCandidate(string key, string type, string translation, MiniYamlNodeBuilder node) + public ExtractionCandidate(string key, string type, string value, MiniYamlNodeBuilder node) { Chrome = null; Key = key; Type = type; - Translation = translation; + Value = value; Nodes = new List() { node }; } } @@ -245,88 +242,69 @@ namespace OpenRA.Mods.Common.UtilityCommands } static void FromChromeLayout( - MiniYamlNodeBuilder node, Dictionary translatables, string container, ref List translations) + MiniYamlNodeBuilder node, Dictionary widgetInfos, string container, ref List candidates) { var nodeSplit = node.Key.Split('@'); - var nodeType = nodeSplit[0]; + var widgetType = nodeSplit[0]; var nodeId = nodeSplit.Length > 1 ? ClearContainersAndToLower(nodeSplit[1]) : null; - if ((nodeType == "Background" || nodeType == "Container") && nodeId != null) + if ((widgetType == "Background" || widgetType == "Container") && nodeId != null) container = nodeId; - // Get translatable types. var validChildTypes = new List<(MiniYamlNodeBuilder Node, string Type, string Value)>(); foreach (var childNode in node.Value.Nodes) { - if (translatables.TryGetValue(nodeType, out var fieldName)) + if (widgetInfos.TryGetValue(widgetType, out var fieldName)) { var childType = childNode.Key.Split('@')[0]; if (fieldName.Contains(childType) && !string.IsNullOrEmpty(childNode.Value.Value) - && !UpdateUtils.IsAlreadyTranslated(childNode.Value.Value) + && !UpdateUtils.IsAlreadyExtracted(childNode.Value.Value) && childNode.Value.Value.Any(char.IsLetterOrDigit)) { - var translationValue = childNode.Value.Value + var value = childNode.Value.Value .Replace("\\n", "\n ") .Replace("{", "<") .Replace("}", ">") .Trim().Trim('\n'); - validChildTypes.Add((childNode, childType.ToLowerInvariant(), translationValue)); + validChildTypes.Add((childNode, childType.ToLowerInvariant(), value)); } } } - // Generate translation key. + // Generate string key. if (validChildTypes.Count > 0) { - nodeType = ClearTypesAndToLower(nodeType); + widgetType = ClearTypesAndToLower(widgetType); - var translationKey = nodeType; + var key = widgetType; if (!string.IsNullOrEmpty(container)) { - var containerType = string.Join('-', container.Split('_').Exclude(nodeType).Where(s => !string.IsNullOrEmpty(s))); + var containerType = string.Join('-', container.Split('_').Exclude(widgetType).Where(s => !string.IsNullOrEmpty(s))); if (!string.IsNullOrEmpty(containerType)) - translationKey = $"{translationKey}-{containerType}"; + key = $"{key}-{containerType}"; } if (!string.IsNullOrEmpty(nodeId)) { nodeId = string.Join('-', nodeId.Split('_') - .Except(string.IsNullOrEmpty(container) ? new string[] { nodeType } : container.Split('_').Append(nodeType)) + .Except(string.IsNullOrEmpty(container) ? new string[] { widgetType } : container.Split('_').Append(widgetType)) .Where(s => !string.IsNullOrEmpty(s))); if (!string.IsNullOrEmpty(nodeId)) - translationKey = $"{translationKey}-{nodeId}"; + key = $"{key}-{nodeId}"; } - foreach (var (childNode, childType, translationValue) in validChildTypes) - translations.Add(new TranslationCandidate(translationKey, childType, translationValue.Trim().Trim('\n'), childNode)); + foreach (var (childNode, childType, childValue) in validChildTypes) + candidates.Add(new ExtractionCandidate(key, childType, childValue.Trim().Trim('\n'), childNode)); } // Recursive. foreach (var childNode in node.Value.Nodes) if (childNode.Key == "Children") foreach (var n in childNode.Value.Nodes) - FromChromeLayout(n, translatables, container, ref translations); - } - - /// This is a helper method to find untranslated strings in chrome layouts. - public static void FindUntranslatedStringFields(ModData modData) - { - var types = modData.ObjectCreator.GetTypes(); - foreach (var (type, fields) in types - .Where(t => t.Name.EndsWith("Widget", StringComparison.InvariantCulture) && t.IsSubclassOf(typeof(Widget))) - .ToDictionary( - t => t.Name[..^6], - t => t - .GetFields() - .Where(f => f.Name != "Id" && f.IsPublic && f.FieldType == typeof(string) && !f.HasAttribute()) - .Distinct() - .Select(f => f.Name) - .ToList())) - if (fields.Count > 0) - Console.WriteLine($"{type}Widget:\n {string.Join("\n ", fields)}"); + FromChromeLayout(n, widgetInfos, container, ref candidates); } } } diff --git a/OpenRA.Mods.Common/UtilityCommands/ExtractYamlStrings.cs b/OpenRA.Mods.Common/UtilityCommands/ExtractYamlStrings.cs index e0362ee2d4..2957a9d311 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ExtractYamlStrings.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ExtractYamlStrings.cs @@ -33,17 +33,17 @@ namespace OpenRA.Mods.Common.UtilityCommands return true; } - [Desc("Extract translatable strings that are not yet localized.")] + [Desc("Extract fluent strings that are not yet localized.")] void IUtilityCommand.Run(Utility utility, string[] args) { // HACK: The engine code assumes that Game.modData is set. var modData = Game.ModData = utility.ModData; - var translatables = modData.ObjectCreator.GetTypes() + var traitInfos = modData.ObjectCreator.GetTypes() .Where(t => t.Name.EndsWith("Info", StringComparison.InvariantCulture) && t.IsSubclassOf(typeof(TraitInfo))) .ToDictionary( t => t.Name[..^4], - t => t.GetFields().Where(f => f.HasAttribute()).Select(f => f.Name).ToArray()) + t => t.GetFields().Where(f => f.HasAttribute()).Select(f => f.Name).ToArray()) .Where(t => t.Value.Length > 0) .ToDictionary(t => t.Key, t => t.Value); @@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.UtilityCommands } var fluentPackage = modData.ModFiles.OpenPackage(modData.Manifest.Id + "|languages"); - ExtractFromFile(Path.Combine(fluentPackage.Name, "rules/en.ftl"), modRules, translatables); + ExtractFromFile(Path.Combine(fluentPackage.Name, "rules/en.ftl"), modRules, traitInfos); modRules.Save(); // Extract from maps. @@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.UtilityCommands mapRules.AddRange(UpdateUtils.LoadInternalMapYaml(modData, package, mapRulesNode.Value, new HashSet())); const string Enftl = "en.ftl"; - ExtractFromFile(Path.Combine(package.Name, Enftl), mapRules, translatables, () => + ExtractFromFile(Path.Combine(package.Name, Enftl), mapRules, traitInfos, () => { var node = yaml.NodeWithKeyOrDefault("Translations"); if (node != null) @@ -102,26 +102,26 @@ namespace OpenRA.Mods.Common.UtilityCommands } } - static void ExtractFromFile(string fluentPath, YamlFileSet yamlSet, Dictionary translatables, Action addTranslation = null) + static void ExtractFromFile(string fluentPath, YamlFileSet yamlSet, Dictionary traitInfos, Action addAction = null) { - var unsortedCandidates = new List(); - var groupedCandidates = new Dictionary, List>(); + var unsortedCandidates = new List(); + var groupedCandidates = new Dictionary, List>(); - // Get all translations. - foreach (var (_, file, nodes) in yamlSet) + // Get all string candidates. + foreach (var (_, file, actors) in yamlSet) { - var translationCandidates = new List(); - foreach (var actor in nodes) + var candidates = new List(); + foreach (var actor in actors) if (actor.Key != null) - ExtractFromActor(actor, translatables, ref translationCandidates); + ExtractFromActor(actor, traitInfos, ref candidates); - if (translationCandidates.Count > 0) + if (candidates.Count > 0) { var ruleFilename = file.Split('/').Last(); - groupedCandidates[new HashSet() { ruleFilename }] = new List(); - for (var i = 0; i < translationCandidates.Count; i++) + groupedCandidates[new HashSet() { ruleFilename }] = new List(); + for (var i = 0; i < candidates.Count; i++) { - var candidate = translationCandidates[i]; + var candidate = candidates[i]; candidate.Filename = ruleFilename; unsortedCandidates.Add(candidate); } @@ -131,16 +131,16 @@ namespace OpenRA.Mods.Common.UtilityCommands if (unsortedCandidates.Count == 0) return; - // Join matching translations. + // Join matching candidates. foreach (var candidate in unsortedCandidates) { HashSet foundHash = null; - TranslationCandidate found = default; - foreach (var (hash, translation) in groupedCandidates) + ExtractionCandidate found = default; + foreach (var (hash, candidates) in groupedCandidates) { - foreach (var c in translation) + foreach (var c in candidates) { - if (c.Actor == candidate.Actor && c.Key == candidate.Key && c.Translation == candidate.Translation) + if (c.Actor == candidate.Actor && c.Key == candidate.Key && c.Value == candidate.Value) { foundHash = hash; found = c; @@ -167,17 +167,17 @@ namespace OpenRA.Mods.Common.UtilityCommands if (nHash.Key != null) groupedCandidates[nHash.Key].Add(candidate); else - groupedCandidates[newHash] = new List() { candidate }; + groupedCandidates[newHash] = new List() { candidate }; } - addTranslation?.Invoke(); + addAction?.Invoke(); // StreamWriter can't create new directories. var startWithNewline = File.Exists(fluentPath); if (!startWithNewline) Directory.CreateDirectory(Path.GetDirectoryName(fluentPath)); - // Write to translation files. + // Write output .ftl files. using (var fluentWriter = new StreamWriter(fluentPath, true)) { foreach (var (filename, candidates) in groupedCandidates.OrderBy(t => string.Join(',', t.Key))) @@ -192,32 +192,32 @@ namespace OpenRA.Mods.Common.UtilityCommands fluentWriter.WriteLine("## " + string.Join(", ", filename)); - // Pushing blocks of translations to string first allows for fancier formatting. + // Pushing blocks to string first allows for fancier formatting. var build = ""; foreach (var grouping in candidates.GroupBy(t => t.Actor)) { if (grouping.Count() == 1) { var candidate = grouping.First(); - var translationKey = $"{candidate.Actor}-{candidate.Key}"; - build += $"{translationKey} = {candidate.Translation}\n"; + var key = $"{candidate.Actor}-{candidate.Key}"; + build += $"{key} = {candidate.Value}\n"; foreach (var node in candidate.Nodes) - node.Value.Value = translationKey; + node.Value.Value = key; } else { if (build.Length > 1 && build.Substring(build.Length - 2, 2) != "\n\n") build += "\n"; - var translationKey = grouping.Key; - build += $"{translationKey} =\n"; + var key = grouping.Key; + build += $"{key} =\n"; foreach (var candidate in grouping) { var type = candidate.Key; - build += $" .{type} = {candidate.Translation}\n"; + build += $" .{type} = {candidate.Value}\n"; foreach (var node in candidate.Nodes) - node.Value.Value = $"{translationKey}.{type}"; + node.Value.Value = $"{key}.{type}"; } build += "\n"; @@ -229,20 +229,20 @@ namespace OpenRA.Mods.Common.UtilityCommands } } - struct TranslationCandidate + struct ExtractionCandidate { public string Filename; public readonly string Actor; public readonly string Key; - public readonly string Translation; + public readonly string Value; public readonly List Nodes; - public TranslationCandidate(string actor, string key, string translation, MiniYamlNodeBuilder node) + public ExtractionCandidate(string actor, string key, string value, MiniYamlNodeBuilder node) { Filename = null; Actor = actor; Key = key; - Translation = translation; + Value = value; Nodes = new List() { node }; } } @@ -279,7 +279,7 @@ namespace OpenRA.Mods.Common.UtilityCommands return s.ToString(); } - static void ExtractFromActor(MiniYamlNodeBuilder actor, Dictionary translatables, ref List translations) + static void ExtractFromActor(MiniYamlNodeBuilder actor, Dictionary traitInfos, ref List candidates) { if (actor.Value?.Nodes == null) return; @@ -291,7 +291,7 @@ namespace OpenRA.Mods.Common.UtilityCommands var traitSplit = trait.Key.Split('@'); var traitInfo = traitSplit[0]; - if (!translatables.TryGetValue(traitInfo, out var translatableType) || trait.Value?.Nodes == null) + if (!traitInfos.TryGetValue(traitInfo, out var type) || trait.Value?.Nodes == null) continue; foreach (var property in trait.Value.Nodes) @@ -300,14 +300,14 @@ namespace OpenRA.Mods.Common.UtilityCommands continue; var propertyType = property.Key.Split('@')[0]; - if (!translatableType.Contains(propertyType)) + if (!type.Contains(propertyType)) continue; var propertyValue = property.Value.Value; - if (string.IsNullOrEmpty(propertyValue) || UpdateUtils.IsAlreadyTranslated(propertyValue) || !propertyValue.Any(char.IsLetterOrDigit)) + if (string.IsNullOrEmpty(propertyValue) || UpdateUtils.IsAlreadyExtracted(propertyValue) || !propertyValue.Any(char.IsLetterOrDigit)) continue; - var translationValue = propertyValue + var value = propertyValue .Replace("\\n", "\n ") .Trim().Trim('\n'); @@ -315,12 +315,12 @@ namespace OpenRA.Mods.Common.UtilityCommands var key = traitInfo; if (traitInfo == nameof(Buildable)) { - translations.Add(new TranslationCandidate(actorName, ToLower(propertyType), translationValue, property)); + candidates.Add(new ExtractionCandidate(actorName, ToLower(propertyType), value, property)); continue; } else if (traitInfo == nameof(Encyclopedia)) { - translations.Add(new TranslationCandidate(actorName, ToLower(traitInfo), translationValue, property)); + candidates.Add(new ExtractionCandidate(actorName, ToLower(traitInfo), value, property)); continue; } else if (traitInfo == nameof(Tooltip) || traitInfo == nameof(EditorOnlyTooltipInfo)[..^4]) @@ -330,7 +330,7 @@ namespace OpenRA.Mods.Common.UtilityCommands else key = propertyType; - translations.Add(new TranslationCandidate(actorName, ToLower(key), translationValue, property)); + candidates.Add(new ExtractionCandidate(actorName, ToLower(key), value, property)); continue; } @@ -339,7 +339,7 @@ namespace OpenRA.Mods.Common.UtilityCommands key += $"-{ToLower(propertyType)}"; - translations.Add(new TranslationCandidate(actorName, key.ToLowerInvariant(), translationValue, property)); + candidates.Add(new ExtractionCandidate(actorName, key.ToLowerInvariant(), value, property)); } } } diff --git a/OpenRA.Mods.Common/Widgets/ButtonWidget.cs b/OpenRA.Mods.Common/Widgets/ButtonWidget.cs index eeeb2a8069..64c7a523e1 100644 --- a/OpenRA.Mods.Common/Widgets/ButtonWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ButtonWidget.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Widgets public bool DisableKeyRepeat = false; public bool DisableKeySound = false; - [TranslationReference] + [FluentReference] public string Text = ""; public TextAlign Align = TextAlign.Center; public int LeftMargin = 5; @@ -55,11 +55,11 @@ namespace OpenRA.Mods.Common.Widgets protected Lazy tooltipContainer; - [TranslationReference] + [FluentReference] public string TooltipText; public Func GetTooltipText; - [TranslationReference] + [FluentReference] public string TooltipDesc; public Func GetTooltipDesc; @@ -77,9 +77,9 @@ namespace OpenRA.Mods.Common.Widgets { ModRules = modData.DefaultRules; - var textCache = new CachedTransform(s => !string.IsNullOrEmpty(s) ? TranslationProvider.GetString(s) : ""); - var tooltipTextCache = new CachedTransform(s => !string.IsNullOrEmpty(s) ? TranslationProvider.GetString(s) : ""); - var tooltipDescCache = new CachedTransform(s => !string.IsNullOrEmpty(s) ? TranslationProvider.GetString(s) : ""); + var textCache = new CachedTransform(s => !string.IsNullOrEmpty(s) ? FluentProvider.GetString(s) : ""); + var tooltipTextCache = new CachedTransform(s => !string.IsNullOrEmpty(s) ? FluentProvider.GetString(s) : ""); + var tooltipDescCache = new CachedTransform(s => !string.IsNullOrEmpty(s) ? FluentProvider.GetString(s) : ""); GetText = () => textCache.Update(Text); GetColor = () => TextColor; diff --git a/OpenRA.Mods.Common/Widgets/ConfirmationDialogs.cs b/OpenRA.Mods.Common/Widgets/ConfirmationDialogs.cs index 92e6a1b187..71ede68678 100644 --- a/OpenRA.Mods.Common/Widgets/ConfirmationDialogs.cs +++ b/OpenRA.Mods.Common/Widgets/ConfirmationDialogs.cs @@ -36,11 +36,11 @@ namespace OpenRA.Mods.Common.Widgets var cancelButton = prompt.GetOrNull("CANCEL_BUTTON"); var otherButton = prompt.GetOrNull("OTHER_BUTTON"); - var titleMessage = TranslationProvider.GetString(title, titleArguments); + var titleMessage = FluentProvider.GetString(title, titleArguments); prompt.Get("PROMPT_TITLE").GetText = () => titleMessage; var headerTemplate = prompt.Get("PROMPT_TEXT"); - var textMessage = TranslationProvider.GetString(text, textArguments); + var textMessage = FluentProvider.GetString(text, textArguments); var headerLines = textMessage.Split('\n'); var headerHeight = 0; foreach (var l in headerLines) @@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Widgets if (!string.IsNullOrEmpty(confirmText)) { - var confirmTextMessage = TranslationProvider.GetString(confirmText); + var confirmTextMessage = FluentProvider.GetString(confirmText); confirmButton.GetText = () => confirmTextMessage; } } @@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Widgets if (!string.IsNullOrEmpty(cancelText)) { - var cancelTextMessage = TranslationProvider.GetString(cancelText); + var cancelTextMessage = FluentProvider.GetString(cancelText); cancelButton.GetText = () => cancelTextMessage; } } @@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Widgets if (!string.IsNullOrEmpty(otherText)) { - var otherTextMessage = TranslationProvider.GetString(otherText); + var otherTextMessage = FluentProvider.GetString(otherText); otherButton.GetText = () => otherTextMessage; } } @@ -114,10 +114,10 @@ namespace OpenRA.Mods.Common.Widgets Func doValidate = null; ButtonWidget acceptButton = null, cancelButton = null; - var titleMessage = TranslationProvider.GetString(title); + var titleMessage = FluentProvider.GetString(title); panel.Get("PROMPT_TITLE").GetText = () => titleMessage; - var promptMessage = TranslationProvider.GetString(prompt); + var promptMessage = FluentProvider.GetString(prompt); panel.Get("PROMPT_TEXT").GetText = () => promptMessage; var input = panel.Get("INPUT_TEXT"); @@ -147,7 +147,7 @@ namespace OpenRA.Mods.Common.Widgets acceptButton = panel.Get("ACCEPT_BUTTON"); if (!string.IsNullOrEmpty(acceptText)) { - var acceptTextMessage = TranslationProvider.GetString(acceptText); + var acceptTextMessage = FluentProvider.GetString(acceptText); acceptButton.GetText = () => acceptTextMessage; } @@ -163,7 +163,7 @@ namespace OpenRA.Mods.Common.Widgets cancelButton = panel.Get("CANCEL_BUTTON"); if (!string.IsNullOrEmpty(cancelText)) { - var cancelTextMessage = TranslationProvider.GetString(cancelText); + var cancelTextMessage = FluentProvider.GetString(cancelText); cancelButton.GetText = () => cancelTextMessage; } diff --git a/OpenRA.Mods.Common/Widgets/ImageWidget.cs b/OpenRA.Mods.Common/Widgets/ImageWidget.cs index 425d1a9772..baefd6d08a 100644 --- a/OpenRA.Mods.Common/Widgets/ImageWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ImageWidget.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Widgets public Func GetImageCollection; public Func GetSprite; - [TranslationReference] + [FluentReference] public string TooltipText; readonly Lazy tooltipContainer; @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Widgets { GetImageName = () => ImageName; GetImageCollection = () => ImageCollection; - var tooltipCache = new CachedTransform(s => !string.IsNullOrEmpty(s) ? TranslationProvider.GetString(s) : ""); + var tooltipCache = new CachedTransform(s => !string.IsNullOrEmpty(s) ? FluentProvider.GetString(s) : ""); GetTooltipText = () => tooltipCache.Update(TooltipText); tooltipContainer = Exts.Lazy(() => Ui.Root.Get(TooltipContainer)); diff --git a/OpenRA.Mods.Common/Widgets/LabelWidget.cs b/OpenRA.Mods.Common/Widgets/LabelWidget.cs index e98dbb973d..0d74011d05 100644 --- a/OpenRA.Mods.Common/Widgets/LabelWidget.cs +++ b/OpenRA.Mods.Common/Widgets/LabelWidget.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Widgets public class LabelWidget : Widget { - [TranslationReference] + [FluentReference] public string Text = null; public TextAlign Align = TextAlign.Left; public TextVAlign VAlign = TextVAlign.Middle; @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Widgets [ObjectCreator.UseCtor] public LabelWidget(ModData modData) { - var textCache = new CachedTransform(s => !string.IsNullOrEmpty(s) ? TranslationProvider.GetString(s) : ""); + var textCache = new CachedTransform(s => !string.IsNullOrEmpty(s) ? FluentProvider.GetString(s) : ""); GetText = () => textCache.Update(Text); GetColor = () => TextColor; GetContrastColorDark = () => ContrastColorDark; diff --git a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs index 816e73748c..407d0df07c 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs @@ -35,10 +35,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic Unknown = 16 } - [TranslationReference("length")] + [FluentReference("length")] const string LengthInSeconds = "label-length-in-seconds"; - [TranslationReference] + [FluentReference] const string AllPackages = "label-all-packages"; readonly string[] allowedExtensions; @@ -96,7 +96,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic this.modData = modData; panel = widget; - allPackages = TranslationProvider.GetString(AllPackages); + allPackages = FluentProvider.GetString(AllPackages); var colorPickerPalettes = world.WorldActor.TraitsImplementing() .SelectMany(p => p.ColorPickerPaletteNames) @@ -238,7 +238,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (frameText != null) { var soundLength = new CachedTransform(p => - TranslationProvider.GetString(LengthInSeconds, Translation.Arguments("length", Math.Round(p, 3)))); + FluentProvider.GetString(LengthInSeconds, FluentBundle.Arguments("length", Math.Round(p, 3)))); frameText.GetText = () => { diff --git a/OpenRA.Mods.Common/Widgets/Logic/ConnectionLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ConnectionLogic.cs index 8c29067c4c..3689c8c580 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ConnectionLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ConnectionLogic.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class ConnectionLogic : ChromeLogic { - [TranslationReference("endpoint")] + [FluentReference("endpoint")] const string ConnectingToEndpoint = "label-connecting-to-endpoint"; readonly Action onConnect; @@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var panel = widget; panel.Get("ABORT_BUTTON").OnClick = () => { CloseWindow(); onAbort(); }; - var connectingDesc = TranslationProvider.GetString(ConnectingToEndpoint, Translation.Arguments("endpoint", endpoint)); + var connectingDesc = FluentProvider.GetString(ConnectingToEndpoint, FluentBundle.Arguments("endpoint", endpoint)); widget.Get("CONNECTING_DESC").GetText = () => connectingDesc; } @@ -87,16 +87,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic public class ConnectionFailedLogic : ChromeLogic { - [TranslationReference("target")] + [FluentReference("target")] const string CouldNotConnectToTarget = "label-could-not-connect-to-target"; - [TranslationReference] + [FluentReference] const string UnknownError = "label-unknown-error"; - [TranslationReference] + [FluentReference] const string PasswordRequired = "label-password-required"; - [TranslationReference] + [FluentReference] const string ConnectionFailed = "label-connection-failed"; readonly PasswordFieldWidget passwordField; @@ -130,17 +130,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic onRetry(pass); }; - var connectingDescText = TranslationProvider.GetString(CouldNotConnectToTarget, Translation.Arguments("target", connection.Target)); + var connectingDescText = FluentProvider.GetString(CouldNotConnectToTarget, FluentBundle.Arguments("target", connection.Target)); widget.Get("CONNECTING_DESC").GetText = () => connectingDescText; var connectionError = widget.Get("CONNECTION_ERROR"); var connectionErrorText = orderManager.ServerError != null - ? TranslationProvider.GetString(orderManager.ServerError) - : connection.ErrorMessage ?? TranslationProvider.GetString(UnknownError); + ? FluentProvider.GetString(orderManager.ServerError) + : connection.ErrorMessage ?? FluentProvider.GetString(UnknownError); connectionError.GetText = () => connectionErrorText; var panelTitle = widget.Get("TITLE"); - var panelTitleText = orderManager.AuthenticationFailed ? TranslationProvider.GetString(PasswordRequired) : TranslationProvider.GetString(ConnectionFailed); + var panelTitleText = orderManager.AuthenticationFailed ? FluentProvider.GetString(PasswordRequired) : FluentProvider.GetString(ConnectionFailed); panelTitle.GetText = () => panelTitleText; passwordField = panel.GetOrNull("PASSWORD"); @@ -182,7 +182,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic public class ConnectionSwitchModLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string ModSwitchFailed = "notification-mod-switch-failed"; [ObjectCreator.UseCtor] diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs index 2850b7be18..78aa9443ec 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs @@ -21,13 +21,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class ActorEditLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string DuplicateActorId = "label-duplicate-actor-id"; - [TranslationReference] + [FluentReference] const string EnterActorId = "label-actor-id"; - [TranslationReference] + [FluentReference] const string Owner = "label-actor-owner"; // Error states define overlapping bits to simplify panel reflow logic @@ -94,8 +94,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic actorIDErrorLabel.IsVisible = () => actorIDStatus != ActorIDStatus.Normal; actorIDErrorLabel.GetText = () => actorIDStatus == ActorIDStatus.Duplicate || nextActorIDStatus == ActorIDStatus.Duplicate - ? TranslationProvider.GetString(DuplicateActorId) - : TranslationProvider.GetString(EnterActorId); + ? FluentProvider.GetString(DuplicateActorId) + : FluentProvider.GetString(EnterActorId); okButton.IsDisabled = () => !IsValid() || editActorPreview == null || !editActorPreview.IsDirty; okButton.OnClick = Save; @@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic initialActorID = actorIDField.Text = SelectedActor.ID; var font = Game.Renderer.Fonts[typeLabel.Font]; - var truncatedType = WidgetUtils.TruncateText(TranslationProvider.GetString(SelectedActor.DescriptiveName), typeLabel.Bounds.Width, font); + var truncatedType = WidgetUtils.TruncateText(FluentProvider.GetString(SelectedActor.DescriptiveName), typeLabel.Bounds.Width, font); typeLabel.GetText = () => truncatedType; actorIDField.CursorPosition = SelectedActor.ID.Length; @@ -180,7 +180,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic // Add owner dropdown var ownerContainer = dropdownOptionTemplate.Clone(); - var owner = TranslationProvider.GetString(Owner); + var owner = FluentProvider.GetString(Owner); ownerContainer.Get("LABEL").GetText = () => owner; var ownerDropdown = ownerContainer.Get("OPTION"); var selectedOwner = SelectedActor.Owner; @@ -439,10 +439,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic sealed class EditActorEditorAction : IEditorAction { - [TranslationReference("name", "id")] + [FluentReference("name", "id")] const string EditedActor = "notification-edited-actor"; - [TranslationReference("name", "old-id", "new-id")] + [FluentReference("name", "old-id", "new-id")] const string EditedActorId = "notification-edited-actor-id"; public string Text { get; private set; } @@ -454,7 +454,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { Actor = actor; this.handles = handles; - Text = TranslationProvider.GetString(EditedActor, Translation.Arguments("name", actor.Info.Name, "id", actor.ID)); + Text = FluentProvider.GetString(EditedActor, FluentBundle.Arguments("name", actor.Info.Name, "id", actor.ID)); } public void Execute() @@ -466,7 +466,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var after = Actor; if (before != after) - Text = TranslationProvider.GetString(EditedActorId, Translation.Arguments("name", after.Info.Name, "old-id", before.ID, "new-id", after.ID)); + Text = FluentProvider.GetString(EditedActorId, FluentBundle.Arguments("name", after.Info.Name, "old-id", before.ID, "new-id", after.ID)); } public void Do() diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs index 97de867d69..cd6caa4077 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class ActorSelectorLogic : CommonSelectorLogic { - [TranslationReference("actorType")] + [FluentReference("actorType")] const string ActorTypeTooltip = "label-actor-type"; sealed class ActorSelectorActor @@ -112,12 +112,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic var tooltip = a.TraitInfos().FirstOrDefault(ti => ti.EnabledByDefault) as TooltipInfoBase ?? a.TraitInfos().FirstOrDefault(ti => ti.EnabledByDefault); - var actorType = TranslationProvider.GetString(ActorTypeTooltip, Translation.Arguments("actorType", a.Name)); + var actorType = FluentProvider.GetString(ActorTypeTooltip, FluentBundle.Arguments("actorType", a.Name)); var searchTerms = new List() { a.Name }; if (tooltip != null) { - var actorName = TranslationProvider.GetString(tooltip.Name); + var actorName = FluentProvider.GetString(tooltip.Name); searchTerms.Add(actorName); allActorsTemp.Add(new ActorSelectorActor(a, editorData.Categories, searchTerms.ToArray(), actorName + $"\n{actorType}")); } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/CommonSelectorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/CommonSelectorLogic.cs index c1bccd9a3d..c4b67ad151 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/CommonSelectorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/CommonSelectorLogic.cs @@ -19,16 +19,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public abstract class CommonSelectorLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string None = "options-common-selector.none"; - [TranslationReference] + [FluentReference] const string SearchResults = "options-common-selector.search-results"; - [TranslationReference] + [FluentReference] const string All = "options-common-selector.all"; - [TranslationReference] + [FluentReference] const string Multiple = "options-common-selector.multiple"; protected readonly Widget Widget; @@ -73,10 +73,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic Editor.DefaultBrush.SelectionChanged += HandleSelectionChanged; - var none = TranslationProvider.GetString(None); - var searchResults = TranslationProvider.GetString(SearchResults); - var all = TranslationProvider.GetString(All); - var multiple = TranslationProvider.GetString(Multiple); + var none = FluentProvider.GetString(None); + var searchResults = FluentProvider.GetString(SearchResults); + var all = FluentProvider.GetString(All); + var multiple = FluentProvider.GetString(Multiple); var categorySelector = widget.Get("CATEGORIES_DROPDOWN"); categorySelector.GetText = () => diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorSelectionLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorSelectionLogic.cs index 4bf5eaa2be..28fb93e153 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorSelectionLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorSelectionLogic.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class MapEditorSelectionLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string AreaSelection = "label-area-selection"; readonly EditorViewportControllerWidget editor; @@ -151,7 +151,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var resourceValueInRegion = editorResourceLayer.CalculateRegionValue(selectedRegion); var areaSelectionLabel = - $"{TranslationProvider.GetString(AreaSelection)} ({DimensionsAsString(selectionSize)}) " + + $"{FluentProvider.GetString(AreaSelection)} ({DimensionsAsString(selectionSize)}) " + $"{PositionAsString(selectedRegion.TopLeft)} : {PositionAsString(selectedRegion.BottomRight)}"; AreaEditTitle.GetText = () => areaSelectionLabel; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapMarkerTilesLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapMarkerTilesLogic.cs index 8bed572eeb..afc5fc54c6 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapMarkerTilesLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapMarkerTilesLogic.cs @@ -22,14 +22,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class MapMarkerTilesLogic : ChromeLogic { - [TranslationReference] - const string MarkerMirrorModeNoneTranslation = "mirror-mode.none"; + [FluentReference] + const string MarkerMirrorModeNone = "mirror-mode.none"; - [TranslationReference] - const string MarkerMirrorModeFlipTranslation = "mirror-mode.flip"; + [FluentReference] + const string MarkerMirrorModeFlip = "mirror-mode.flip"; - [TranslationReference] - const string MarkerMirrorModeRotateTranslation = "mirror-mode.rotate"; + [FluentReference] + const string MarkerMirrorModeRotate = "mirror-mode.rotate"; readonly EditorActionManager editorActionManager; readonly MarkerLayerOverlay markerLayerTrait; @@ -130,13 +130,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic switch (markerLayerTrait.MirrorMode) { case MarkerTileMirrorMode.None: - return TranslationProvider.GetString(MarkerMirrorModeNoneTranslation); + return FluentProvider.GetString(MarkerMirrorModeNone); case MarkerTileMirrorMode.Flip: - return TranslationProvider.GetString(MarkerMirrorModeFlipTranslation); + return FluentProvider.GetString(MarkerMirrorModeFlip); case MarkerTileMirrorMode.Rotate: - return TranslationProvider.GetString(MarkerMirrorModeRotateTranslation); + return FluentProvider.GetString(MarkerMirrorModeRotate); default: - throw new ArgumentException($"Couldn't find translation for marker tile mirror mode '{markerLayerTrait.MirrorMode}'"); + throw new ArgumentException($"Couldn't find fluent string for marker tile mirror mode '{markerLayerTrait.MirrorMode}'"); } }; @@ -221,13 +221,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic switch (mode) { case MarkerTileMirrorMode.None: - return TranslationProvider.GetString(MarkerMirrorModeNoneTranslation); + return FluentProvider.GetString(MarkerMirrorModeNone); case MarkerTileMirrorMode.Flip: - return TranslationProvider.GetString(MarkerMirrorModeFlipTranslation); + return FluentProvider.GetString(MarkerMirrorModeFlip); case MarkerTileMirrorMode.Rotate: - return TranslationProvider.GetString(MarkerMirrorModeRotateTranslation); + return FluentProvider.GetString(MarkerMirrorModeRotate); default: - throw new ArgumentException($"Couldn't find translation for marker tile mirror mode '{mode}'"); + throw new ArgumentException($"Couldn't find fluent string for marker tile mirror mode '{mode}'"); } }; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapToolsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapToolsLogic.cs index 0f9f2d8a8e..262d122569 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapToolsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapToolsLogic.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class MapToolsLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string MarkerTiles = "label-tool-marker-tiles"; enum MapTool @@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic toolPanels.Add(MapTool.MarkerTiles, markerToolPanel); toolsDropdown.OnMouseDown = _ => ShowToolsDropDown(toolsDropdown); - toolsDropdown.GetText = () => TranslationProvider.GetString(toolNames[selectedTool]); + toolsDropdown.GetText = () => FluentProvider.GetString(toolNames[selectedTool]); toolsDropdown.Disabled = true; // TODO: Enable if new tools are added } @@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic () => selectedTool == tool, () => SelectTool(tool)); - item.Get("LABEL").GetText = () => TranslationProvider.GetString(toolNames[tool]); + item.Get("LABEL").GetText = () => FluentProvider.GetString(toolNames[tool]); return item; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/SaveMapLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/SaveMapLogic.cs index f2326fe9f2..ec8c2e4470 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/SaveMapLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/SaveMapLogic.cs @@ -44,37 +44,37 @@ namespace OpenRA.Mods.Common.Widgets.Logic } } - [TranslationReference] + [FluentReference] const string SaveMapFailedTitle = "dialog-save-map-failed.title"; - [TranslationReference] + [FluentReference] const string SaveMapFailedPrompt = "dialog-save-map-failed.prompt"; - [TranslationReference] + [FluentReference] const string SaveMapFailedConfirm = "dialog-save-map-failed.confirm"; - [TranslationReference] + [FluentReference] const string Unpacked = "label-unpacked-map"; - [TranslationReference] + [FluentReference] const string OverwriteMapFailedTitle = "dialog-overwrite-map-failed.title"; - [TranslationReference] + [FluentReference] const string OverwriteMapFailedPrompt = "dialog-overwrite-map-failed.prompt"; - [TranslationReference] + [FluentReference] const string OverwriteMapFailedConfirm = "dialog-overwrite-map-failed.confirm"; - [TranslationReference] + [FluentReference] const string OverwriteMapOutsideEditTitle = "dialog-overwrite-map-outside-edit.title"; - [TranslationReference] + [FluentReference] const string OverwriteMapOutsideEditPrompt = "dialog-overwrite-map-outside-edit.prompt"; - [TranslationReference] + [FluentReference] const string SaveMapMapOutsideConfirm = "dialog-overwrite-map-outside-edit.confirm"; - [TranslationReference] + [FluentReference] const string SaveCurrentMap = "notification-save-current-map"; [ObjectCreator.UseCtor] @@ -171,7 +171,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var fileTypes = new Dictionary() { { MapFileType.OraMap, new MapFileTypeInfo { Extension = ".oramap", UiLabel = ".oramap" } }, - { MapFileType.Unpacked, new MapFileTypeInfo { Extension = "", UiLabel = $"({TranslationProvider.GetString(Unpacked)})" } } + { MapFileType.Unpacked, new MapFileTypeInfo { Extension = "", UiLabel = $"({FluentProvider.GetString(Unpacked)})" } } }; var typeDropdown = widget.Get("TYPE_DROPDOWN"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/EncyclopediaLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/EncyclopediaLogic.cs index 117d6351a0..3783e0a564 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/EncyclopediaLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/EncyclopediaLogic.cs @@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var label = item.Get("TITLE"); var name = actor.TraitInfos().FirstOrDefault(info => info.EnabledByDefault)?.Name; if (!string.IsNullOrEmpty(name)) - WidgetUtils.TruncateLabelToTooltip(label, TranslationProvider.GetString(name)); + WidgetUtils.TruncateLabelToTooltip(label, FluentProvider.GetString(name)); if (firstItem == null) { @@ -159,7 +159,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var info = actor.TraitInfoOrDefault(); if (info != null && !string.IsNullOrEmpty(info.Description)) - text += WidgetUtils.WrapText(TranslationProvider.GetString(info.Description) + "\n\n", descriptionLabel.Bounds.Width, descriptionFont); + text += WidgetUtils.WrapText(FluentProvider.GetString(info.Description) + "\n\n", descriptionLabel.Bounds.Width, descriptionFont); var height = descriptionFont.Measure(text).Y; descriptionLabel.GetText = () => text; @@ -175,7 +175,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var actorTooltip = actor.TraitInfos().FirstOrDefault(info => info.EnabledByDefault); if (actorTooltip != null) - return TranslationProvider.GetString(actorTooltip.Name); + return FluentProvider.GetString(actorTooltip.Name); } return name; diff --git a/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs index 2d2f5b72dc..b79a9ed12b 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs @@ -21,43 +21,43 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class GameSaveBrowserLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string RenameSaveTitle = "dialog-rename-save.title"; - [TranslationReference] + [FluentReference] const string RenameSavePrompt = "dialog-rename-save.prompt"; - [TranslationReference] + [FluentReference] const string RenameSaveAccept = "dialog-rename-save.confirm"; - [TranslationReference] + [FluentReference] const string DeleteSaveTitle = "dialog-delete-save.title"; - [TranslationReference("save")] + [FluentReference("save")] const string DeleteSavePrompt = "dialog-delete-save.prompt"; - [TranslationReference] + [FluentReference] const string DeleteSaveAccept = "dialog-delete-save.confirm"; - [TranslationReference] + [FluentReference] const string DeleteAllSavesTitle = "dialog-delete-all-saves.title"; - [TranslationReference("count")] + [FluentReference("count")] const string DeleteAllSavesPrompt = "dialog-delete-all-saves.prompt"; - [TranslationReference] + [FluentReference] const string DeleteAllSavesAccept = "dialog-delete-all-saves.confirm"; - [TranslationReference("savePath")] + [FluentReference("savePath")] const string SaveDeletionFailed = "notification-save-deletion-failed"; - [TranslationReference] + [FluentReference] const string OverwriteSaveTitle = "dialog-overwrite-save.title"; - [TranslationReference("file")] + [FluentReference("file")] const string OverwriteSavePrompt = "dialog-overwrite-save.prompt"; - [TranslationReference] + [FluentReference] const string OverwriteSaveAccpet = "dialog-overwrite-save.confirm"; readonly Widget panel; @@ -173,7 +173,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: DeleteSaveTitle, text: DeleteSavePrompt, - textArguments: Translation.Arguments("save", Path.GetFileNameWithoutExtension(selectedSave)), + textArguments: FluentBundle.Arguments("save", Path.GetFileNameWithoutExtension(selectedSave)), onConfirm: () => { Delete(selectedSave); @@ -197,7 +197,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: DeleteAllSavesTitle, text: DeleteAllSavesPrompt, - textArguments: Translation.Arguments("count", games.Count), + textArguments: FluentBundle.Arguments("count", games.Count), onConfirm: () => { foreach (var s in games.ToList()) @@ -293,7 +293,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } catch (Exception ex) { - TextNotificationsManager.Debug(TranslationProvider.GetString(SaveDeletionFailed, Translation.Arguments("savePath", savePath))); + TextNotificationsManager.Debug(FluentProvider.GetString(SaveDeletionFailed, FluentBundle.Arguments("savePath", savePath))); Log.Write("debug", ex.ToString()); return; } @@ -373,7 +373,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: OverwriteSaveTitle, text: OverwriteSavePrompt, - textArguments: Translation.Arguments("file", saveTextField.Text), + textArguments: FluentBundle.Arguments("file", saveTextField.Text), onConfirm: Inner, confirmText: OverwriteSaveAccpet, onCancel: () => { }); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ArmyTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ArmyTooltipLogic.cs index f0bf899c3b..aa57b5bfd2 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ArmyTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ArmyTooltipLogic.cs @@ -38,13 +38,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic return; var tooltip = armyUnit.TooltipInfo; - var name = tooltip != null ? TranslationProvider.GetString(tooltip.Name) : armyUnit.ActorInfo.Name; + var name = tooltip != null ? FluentProvider.GetString(tooltip.Name) : armyUnit.ActorInfo.Name; var buildable = armyUnit.BuildableInfo; nameLabel.GetText = () => name; var nameSize = font.Measure(name); - var desc = string.IsNullOrEmpty(buildable.Description) ? "" : TranslationProvider.GetString(buildable.Description); + var desc = string.IsNullOrEmpty(buildable.Description) ? "" : FluentProvider.GetString(buildable.Description); descLabel.GetText = () => desc; var descSize = descFont.Measure(desc); descLabel.Bounds.Width = descSize.X; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoLogic.cs index b4e43e7a7f..60838552bf 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoLogic.cs @@ -22,19 +22,19 @@ namespace OpenRA.Mods.Common.Widgets.Logic sealed class GameInfoLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string Objectives = "menu-game-info.objectives"; - [TranslationReference] + [FluentReference] const string Briefing = "menu-game-info.briefing"; - [TranslationReference] + [FluentReference] const string Options = "menu-game-info.options"; - [TranslationReference] + [FluentReference] const string Debug = "menu-game-info.debug"; - [TranslationReference] + [FluentReference] const string Chat = "menu-game-info.chat"; readonly World world; @@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (tabButton != null) { - var tabButtonText = TranslationProvider.GetString(label); + var tabButtonText = FluentProvider.GetString(label); tabButton.GetText = () => tabButtonText; tabButton.OnClick = () => { diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoObjectivesLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoObjectivesLogic.cs index 9ea3a8c756..7f41dc1d8d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoObjectivesLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoObjectivesLogic.cs @@ -18,13 +18,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic { sealed class GameInfoObjectivesLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string InProgress = "label-mission-in-progress"; - [TranslationReference] + [FluentReference] const string Accomplished = "label-mission-accomplished"; - [TranslationReference] + [FluentReference] const string Failed = "label-mission-failed"; readonly ContainerWidget template; @@ -51,9 +51,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic } var missionStatus = widget.Get("MISSION_STATUS"); - var inProgress = TranslationProvider.GetString(InProgress); - var accomplished = TranslationProvider.GetString(Accomplished); - var failed = TranslationProvider.GetString(Failed); + var inProgress = FluentProvider.GetString(InProgress); + var accomplished = FluentProvider.GetString(Accomplished); + var failed = FluentProvider.GetString(Failed); missionStatus.GetText = () => player.WinState == WinState.Undefined ? inProgress : player.WinState == WinState.Won ? accomplished : failed; missionStatus.GetColor = () => player.WinState == WinState.Undefined ? Color.White : diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs index 87ca226ea8..ff6c8e221e 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs @@ -23,67 +23,67 @@ namespace OpenRA.Mods.Common.Widgets.Logic { sealed class GameInfoStatsLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string Unmute = "label-unmute-player"; - [TranslationReference] + [FluentReference] const string Mute = "label-mute-player"; - [TranslationReference] + [FluentReference] const string Accomplished = "label-mission-accomplished"; - [TranslationReference] + [FluentReference] const string Failed = "label-mission-failed"; - [TranslationReference] + [FluentReference] const string InProgress = "label-mission-in-progress"; - [TranslationReference("team")] + [FluentReference("team")] const string TeamNumber = "label-team-name"; - [TranslationReference] + [FluentReference] const string NoTeam = "label-no-team"; - [TranslationReference] + [FluentReference] const string Spectators = "label-spectators"; - [TranslationReference] + [FluentReference] const string Gone = "label-client-state-disconnected"; - [TranslationReference] + [FluentReference] const string KickTooltip = "button-kick-player"; - [TranslationReference("player")] + [FluentReference("player")] const string KickTitle = "dialog-kick.title"; - [TranslationReference] + [FluentReference] const string KickPrompt = "dialog-kick.prompt"; - [TranslationReference] + [FluentReference] const string KickAccept = "dialog-kick.confirm"; - [TranslationReference] + [FluentReference] const string KickVoteTooltip = "button-vote-kick-player"; - [TranslationReference("player")] + [FluentReference("player")] const string VoteKickTitle = "dialog-vote-kick.title"; - [TranslationReference] + [FluentReference] const string VoteKickPrompt = "dialog-vote-kick.prompt"; - [TranslationReference("bots")] + [FluentReference("bots")] const string VoteKickPromptBreakBots = "dialog-vote-kick.prompt-break-bots"; - [TranslationReference] + [FluentReference] const string VoteKickVoteStart = "dialog-vote-kick.vote-start"; - [TranslationReference] + [FluentReference] const string VoteKickVoteFor = "dialog-vote-kick.vote-for"; - [TranslationReference] + [FluentReference] const string VoteKickVoteAgainst = "dialog-vote-kick.vote-against"; - [TranslationReference] + [FluentReference] const string VoteKickVoteCancel = "dialog-vote-kick.vote-cancel"; [ObjectCreator.UseCtor] @@ -108,9 +108,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic checkbox.GetText = () => mo.Objectives[0].Description; } - var failed = TranslationProvider.GetString(Failed); - var inProgress = TranslationProvider.GetString(InProgress); - var accomplished = TranslationProvider.GetString(Accomplished); + var failed = FluentProvider.GetString(Failed); + var inProgress = FluentProvider.GetString(InProgress); + var accomplished = FluentProvider.GetString(Accomplished); statusLabel.GetText = () => player.WinState == WinState.Won ? accomplished : player.WinState == WinState.Lost ? failed : inProgress; statusLabel.GetColor = () => player.WinState == WinState.Won ? Color.LimeGreen : @@ -133,10 +133,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic var teamTemplate = playerPanel.Get("TEAM_TEMPLATE"); var playerTemplate = playerPanel.Get("PLAYER_TEMPLATE"); var spectatorTemplate = playerPanel.Get("SPECTATOR_TEMPLATE"); - var unmuteTooltip = TranslationProvider.GetString(Unmute); - var muteTooltip = TranslationProvider.GetString(Mute); - var kickTooltip = TranslationProvider.GetString(KickTooltip); - var voteKickTooltip = TranslationProvider.GetString(KickVoteTooltip); + var unmuteTooltip = FluentProvider.GetString(Unmute); + var muteTooltip = FluentProvider.GetString(Mute); + var kickTooltip = FluentProvider.GetString(KickTooltip); + var voteKickTooltip = FluentProvider.GetString(KickVoteTooltip); playerPanel.RemoveChildren(); var teams = world.Players.Where(p => !p.NonCombatant && p.Playable) @@ -160,8 +160,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: VoteKickTitle, text: botsCount > 0 ? VoteKickPromptBreakBots : VoteKickPrompt, - titleArguments: Translation.Arguments("player", client.Name), - textArguments: Translation.Arguments("bots", botsCount), + titleArguments: FluentBundle.Arguments("player", client.Name), + textArguments: FluentBundle.Arguments("bots", botsCount), onConfirm: () => { orderManager.IssueOrder(Order.Command($"vote_kick {client.Index} {true}")); @@ -176,8 +176,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: VoteKickTitle, text: botsCount > 0 ? VoteKickPromptBreakBots : VoteKickPrompt, - titleArguments: Translation.Arguments("player", client.Name), - textArguments: Translation.Arguments("bots", botsCount), + titleArguments: FluentBundle.Arguments("player", client.Name), + textArguments: FluentBundle.Arguments("bots", botsCount), onConfirm: () => { orderManager.IssueOrder(Order.Command($"vote_kick {client.Index} {true}")); @@ -201,7 +201,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: KickTitle, text: KickPrompt, - titleArguments: Translation.Arguments("player", client.Name), + titleArguments: FluentBundle.Arguments("player", client.Name), onConfirm: () => { orderManager.IssueOrder(Order.Command($"kick {client.Index} {false}")); @@ -227,8 +227,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var teamHeader = ScrollItemWidget.Setup(teamTemplate, () => false, () => { }); var team = t.Key > 0 - ? TranslationProvider.GetString(TeamNumber, Translation.Arguments("team", t.Key)) - : TranslationProvider.GetString(NoTeam); + ? FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", t.Key)) + : FluentProvider.GetString(NoTeam); teamHeader.Get("TEAM").GetText = () => team; var teamRating = teamHeader.Get("TEAM_SCORE"); var scoreCache = new CachedTransform(s => s.ToString(NumberFormatInfo.CurrentInfo)); @@ -257,13 +257,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic { flag.GetImageName = () => pp.Faction.InternalName; factionName = pp.Faction.Name != factionName - ? $"{TranslationProvider.GetString(factionName)} ({TranslationProvider.GetString(pp.Faction.Name)})" - : TranslationProvider.GetString(pp.Faction.Name); + ? $"{FluentProvider.GetString(factionName)} ({FluentProvider.GetString(pp.Faction.Name)})" + : FluentProvider.GetString(pp.Faction.Name); } else { flag.GetImageName = () => pp.DisplayFaction.InternalName; - factionName = TranslationProvider.GetString(factionName); + factionName = FluentProvider.GetString(factionName); } WidgetUtils.TruncateLabelToTooltip(item.Get("FACTION"), factionName); @@ -291,7 +291,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (spectators.Count > 0) { var spectatorHeader = ScrollItemWidget.Setup(teamTemplate, () => false, () => { }); - var spectatorTeam = TranslationProvider.GetString(Spectators); + var spectatorTeam = FluentProvider.GetString(Spectators); spectatorHeader.Get("TEAM").GetText = () => spectatorTeam; playerPanel.AddChild(spectatorHeader); @@ -310,7 +310,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic nameLabel.GetText = () => { - var suffix = client.State == Session.ClientState.Disconnected ? $" ({TranslationProvider.GetString(Gone)})" : ""; + var suffix = client.State == Session.ClientState.Disconnected ? $" ({FluentProvider.GetString(Gone)})" : ""; return name.Update((client.Name, suffix)); }; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameTimerLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameTimerLogic.cs index 53d7021dbd..487b553356 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameTimerLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameTimerLogic.cs @@ -19,16 +19,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class GameTimerLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string Paused = "label-paused"; - [TranslationReference] + [FluentReference] const string MaxSpeed = "label-max-speed"; - [TranslationReference("percentage")] + [FluentReference("percentage")] const string Speed = "label-replay-speed"; - [TranslationReference("percentage")] + [FluentReference("percentage")] const string Complete = "label-replay-complete"; [ObjectCreator.UseCtor] @@ -44,10 +44,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic bool Paused() => world.Paused || world.ReplayTimestep == 0; - var pausedText = TranslationProvider.GetString(GameTimerLogic.Paused); - var maxSpeedText = TranslationProvider.GetString(MaxSpeed); + var pausedText = FluentProvider.GetString(GameTimerLogic.Paused); + var maxSpeedText = FluentProvider.GetString(MaxSpeed); var speedText = new CachedTransform(p => - TranslationProvider.GetString(Speed, Translation.Arguments("percentage", p))); + FluentProvider.GetString(Speed, FluentBundle.Arguments("percentage", p))); if (timer != null) { @@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } var timerText = new CachedTransform(p => - TranslationProvider.GetString(Complete, Translation.Arguments("percentage", p))); + FluentProvider.GetString(Complete, FluentBundle.Arguments("percentage", p))); if (timer is LabelWithTooltipWidget timerTooltip) { var connection = orderManager.Connection as ReplayConnection; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectAllUnitsHotkeyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectAllUnitsHotkeyLogic.cs index 1c6821470a..c2a5e50c8f 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectAllUnitsHotkeyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectAllUnitsHotkeyLogic.cs @@ -27,10 +27,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame public readonly string ClickSound = ChromeMetrics.Get("ClickSound"); - [TranslationReference("units")] + [FluentReference("units")] const string SelectedUnitsAcrossScreen = "selected-units-across-screen"; - [TranslationReference("units")] + [FluentReference("units")] const string SelectedUnitsAcrossMap = "selected-units-across-map"; [ObjectCreator.UseCtor] @@ -54,12 +54,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame // Check if selecting actors on the screen has selected new units if (newSelection.Count > selection.Actors.Count) - TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossScreen, Translation.Arguments("units", newSelection.Count)); + TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossScreen, FluentBundle.Arguments("units", newSelection.Count)); else { // Select actors in the world that have highest selection priority newSelection = SelectionUtils.SelectActorsInWorld(world, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList(); - TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossMap, Translation.Arguments("units", newSelection.Count)); + TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossMap, FluentBundle.Arguments("units", newSelection.Count)); } selection.Combine(world, newSelection, false, false); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectUnitsByTypeHotkeyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectUnitsByTypeHotkeyLogic.cs index 6e95cdebbf..6a1a3976a1 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectUnitsByTypeHotkeyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/SelectUnitsByTypeHotkeyLogic.cs @@ -29,13 +29,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame public readonly string ClickSound = ChromeMetrics.Get("ClickSound"); public readonly string ClickDisabledSound = ChromeMetrics.Get("ClickDisabledSound"); - [TranslationReference] + [FluentReference] const string NothingSelected = "nothing-selected"; - [TranslationReference("units")] + [FluentReference("units")] const string SelectedUnitsAcrossScreen = "selected-units-across-screen"; - [TranslationReference("units")] + [FluentReference("units")] const string SelectedUnitsAcrossMap = "selected-units-across-map"; [ObjectCreator.UseCtor] @@ -79,12 +79,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame // Check if selecting actors on the screen has selected new units if (newSelection.Count > selection.Actors.Count) - TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossScreen, Translation.Arguments("units", newSelection.Count)); + TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossScreen, FluentBundle.Arguments("units", newSelection.Count)); else { // Select actors in the world that have the same selection class as one of the already selected actors newSelection = SelectionUtils.SelectActorsInWorld(world, selectedClasses, eligiblePlayers).ToList(); - TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossMap, Translation.Arguments("units", newSelection.Count)); + TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossMap, FluentBundle.Arguments("units", newSelection.Count)); } selection.Combine(world, newSelection, true, false); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameCashCounterLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameCashCounterLogic.cs index 5c97eb05d0..9810a1c11e 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameCashCounterLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameCashCounterLogic.cs @@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class IngameCashCounterLogic : ChromeLogic { - [TranslationReference("usage", "capacity")] + [FluentReference("usage", "capacity")] const string SiloUsage = "label-silo-usage"; const float DisplayFracPerFrame = .07f; @@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic displayResources = playerResources.GetCashAndResources(); siloUsageTooltipCache = new CachedTransform<(int Resources, int Capacity), string>(x => - TranslationProvider.GetString(SiloUsage, Translation.Arguments("usage", x.Resources, "capacity", x.Capacity))); + FluentProvider.GetString(SiloUsage, FluentBundle.Arguments("usage", x.Resources, "capacity", x.Capacity))); cashLabel = widget.Get("CASH"); cashLabel.GetTooltipText = () => siloUsageTooltip; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs index be902e4d9f..6aa169c6cc 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs @@ -23,16 +23,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic [ChromeLogicArgsHotkeys("OpenTeamChat", "OpenGeneralChat")] public class IngameChatLogic : ChromeLogic, INotificationHandler { - [TranslationReference] + [FluentReference] const string TeamChat = "button-team-chat"; - [TranslationReference] + [FluentReference] const string GeneralChat = "button-general-chat"; - [TranslationReference("seconds")] + [FluentReference("seconds")] const string ChatAvailability = "label-chat-availability"; - [TranslationReference] + [FluentReference] const string ChatDisabled = "label-chat-disabled"; readonly Ruleset modRules; @@ -70,10 +70,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic var disableTeamChat = alwaysDisabled || (world.LocalPlayer != null && !players.Any(p => p.IsAlliedWith(world.LocalPlayer))); var teamChat = !disableTeamChat; - var teamMessage = TranslationProvider.GetString(TeamChat); - var allMessage = TranslationProvider.GetString(GeneralChat); + var teamMessage = FluentProvider.GetString(TeamChat); + var allMessage = FluentProvider.GetString(GeneralChat); - chatDisabled = TranslationProvider.GetString(ChatDisabled); + chatDisabled = FluentProvider.GetString(ChatDisabled); // Only execute this once, the first time this widget is loaded if (TextNotificationsManager.MutedPlayers.Count == 0) @@ -194,7 +194,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic return true; }; - chatAvailableIn = new CachedTransform(x => TranslationProvider.GetString(ChatAvailability, Translation.Arguments("seconds", x))); + chatAvailableIn = new CachedTransform(x => FluentProvider.GetString(ChatAvailability, FluentBundle.Arguments("seconds", x))); if (!isMenuChat) { diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs index 24e9b58ce9..57a64ae611 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs @@ -21,121 +21,121 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class IngameMenuLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string Leave = "menu-ingame.leave"; - [TranslationReference] + [FluentReference] const string AbortMission = "menu-ingame.abort"; - [TranslationReference] + [FluentReference] const string LeaveMissionTitle = "dialog-leave-mission.title"; - [TranslationReference] + [FluentReference] const string LeaveMissionPrompt = "dialog-leave-mission.prompt"; - [TranslationReference] + [FluentReference] const string LeaveMissionAccept = "dialog-leave-mission.confirm"; - [TranslationReference] + [FluentReference] const string LeaveMissionCancel = "dialog-leave-mission.cancel"; - [TranslationReference] + [FluentReference] const string RestartButton = "menu-ingame.restart"; - [TranslationReference] + [FluentReference] const string RestartMissionTitle = "dialog-restart-mission.title"; - [TranslationReference] + [FluentReference] const string RestartMissionPrompt = "dialog-restart-mission.prompt"; - [TranslationReference] + [FluentReference] const string RestartMissionAccept = "dialog-restart-mission.confirm"; - [TranslationReference] + [FluentReference] const string RestartMissionCancel = "dialog-restart-mission.cancel"; - [TranslationReference] + [FluentReference] const string SurrenderButton = "menu-ingame.surrender"; - [TranslationReference] + [FluentReference] const string SurrenderTitle = "dialog-surrender.title"; - [TranslationReference] + [FluentReference] const string SurrenderPrompt = "dialog-surrender.prompt"; - [TranslationReference] + [FluentReference] const string SurrenderAccept = "dialog-surrender.confirm"; - [TranslationReference] + [FluentReference] const string SurrenderCancel = "dialog-surrender.cancel"; - [TranslationReference] + [FluentReference] const string LoadGameButton = "menu-ingame.load-game"; - [TranslationReference] + [FluentReference] const string SaveGameButton = "menu-ingame.save-game"; - [TranslationReference] + [FluentReference] const string MusicButton = "menu-ingame.music"; - [TranslationReference] + [FluentReference] const string SettingsButton = "menu-ingame.settings"; - [TranslationReference] + [FluentReference] const string ReturnToMap = "menu-ingame.return-to-map"; - [TranslationReference] + [FluentReference] const string Resume = "menu-ingame.resume"; - [TranslationReference] + [FluentReference] const string SaveMapButton = "menu-ingame.save-map"; - [TranslationReference] + [FluentReference] const string ErrorMaxPlayerTitle = "dialog-error-max-player.title"; - [TranslationReference("players", "max")] + [FluentReference("players", "max")] const string ErrorMaxPlayerPrompt = "dialog-error-max-player.prompt"; - [TranslationReference] + [FluentReference] const string ErrorMaxPlayerAccept = "dialog-error-max-player.confirm"; - [TranslationReference] + [FluentReference] const string ExitMapButton = "menu-ingame.exit-map"; - [TranslationReference] + [FluentReference] const string ExitMapEditorTitle = "dialog-exit-map-editor.title"; - [TranslationReference] + [FluentReference] const string ExitMapEditorPromptUnsaved = "dialog-exit-map-editor.prompt-unsaved"; - [TranslationReference] + [FluentReference] const string ExitMapEditorPromptDeleted = "dialog-exit-map-editor.prompt-deleted"; - [TranslationReference] + [FluentReference] const string ExitMapEditorAnywayConfirm = "dialog-exit-map-editor.confirm-anyway"; - [TranslationReference] + [FluentReference] const string ExitMapEditorConfirm = "dialog-exit-map-editor.confirm"; - [TranslationReference] + [FluentReference] const string PlayMapWarningTitle = "dialog-play-map-warning.title"; - [TranslationReference] + [FluentReference] const string PlayMapWarningPrompt = "dialog-play-map-warning.prompt"; - [TranslationReference] + [FluentReference] const string PlayMapWarningCancel = "dialog-play-map-warning.cancel"; - [TranslationReference] + [FluentReference] const string ExitToMapEditorTitle = "dialog-exit-to-map-editor.title"; - [TranslationReference] + [FluentReference] const string ExitToMapEditorPrompt = "dialog-exit-to-map-editor.prompt"; - [TranslationReference] + [FluentReference] const string ExitToMapEditorConfirm = "dialog-exit-to-map-editor.confirm"; - [TranslationReference] + [FluentReference] const string ExitToMapEditorCancel = "dialog-exit-to-map-editor.cancel"; readonly Widget menu; @@ -293,7 +293,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic Ui.ResetTooltips(); } - ButtonWidget AddButton(string id, string text) + ButtonWidget AddButton(string id, string label) { var button = buttonTemplate.Clone() as ButtonWidget; var lastButton = buttons.LastOrDefault(); @@ -305,8 +305,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic button.Id = id; button.IsDisabled = () => leaving; - var translation = TranslationProvider.GetString(text); - button.GetText = () => translation; + var text = FluentProvider.GetString(label); + button.GetText = () => text; buttonContainer.AddChild(button); buttons.Add(button); @@ -319,8 +319,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic return; var button = AddButton("ABORT_MISSION", world.IsGameOver - ? TranslationProvider.GetString(Leave) - : TranslationProvider.GetString(AbortMission)); + ? FluentProvider.GetString(Leave) + : FluentProvider.GetString(AbortMission)); button.OnClick = () => { @@ -494,7 +494,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: ErrorMaxPlayerTitle, text: ErrorMaxPlayerPrompt, - textArguments: Translation.Arguments("players", playerCount, "max", MapPlayers.MaximumPlayerCount), + textArguments: FluentBundle.Arguments("players", playerCount, "max", MapPlayers.MaximumPlayerCount), onConfirm: ShowMenu, confirmText: ErrorMaxPlayerAccept); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerBarLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerBarLogic.cs index 64150a0b77..03388961e4 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerBarLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerBarLogic.cs @@ -18,10 +18,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class IngamePowerBarLogic : ChromeLogic { - [TranslationReference("usage", "capacity")] + [FluentReference("usage", "capacity")] const string PowerUsage = "label-power-usage"; - [TranslationReference] + [FluentReference] const string Infinite = "label-infinite-power"; [ObjectCreator.UseCtor] @@ -36,12 +36,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic powerBar.TooltipTextCached = new CachedTransform<(float Current, float Capacity), string>(usage => { var capacity = developerMode.UnlimitedPower ? - TranslationProvider.GetString(Infinite) : + FluentProvider.GetString(Infinite) : powerManager.PowerProvided.ToString(NumberFormatInfo.CurrentInfo); - return TranslationProvider.GetString( + return FluentProvider.GetString( PowerUsage, - Translation.Arguments("usage", usage.Current, "capacity", capacity)); + FluentBundle.Arguments("usage", usage.Current, "capacity", capacity)); }); powerBar.GetBarColor = () => diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs index 60f15d2600..5a6271b0cd 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs @@ -18,10 +18,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class IngamePowerCounterLogic : ChromeLogic { - [TranslationReference("usage", "capacity")] + [FluentReference("usage", "capacity")] const string PowerUsage = "label-power-usage"; - [TranslationReference] + [FluentReference] const string Infinite = "label-infinite-power"; [ObjectCreator.UseCtor] @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var powerManager = world.LocalPlayer.PlayerActor.Trait(); var power = widget.Get("POWER"); var powerIcon = widget.Get("POWER_ICON"); - var unlimitedCapacity = TranslationProvider.GetString(Infinite); + var unlimitedCapacity = FluentProvider.GetString(Infinite); powerIcon.GetImageName = () => powerManager.ExcessPower < 0 ? "power-critical" : "power-normal"; power.GetColor = () => powerManager.ExcessPower < 0 ? Color.Red : Color.White; @@ -41,9 +41,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic var tooltipTextCached = new CachedTransform<(int, int?), string>(((int Usage, int? Capacity) args) => { var capacity = args.Capacity == null ? unlimitedCapacity : args.Capacity.Value.ToString(NumberFormatInfo.CurrentInfo); - return TranslationProvider.GetString( + return FluentProvider.GetString( PowerUsage, - Translation.Arguments( + FluentBundle.Arguments( "usage", args.Usage.ToString(NumberFormatInfo.CurrentInfo), "capacity", capacity)); }); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameSiloBarLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameSiloBarLogic.cs index 3f45d17568..348a58550d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameSiloBarLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameSiloBarLogic.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class IngameSiloBarLogic : ChromeLogic { - [TranslationReference("usage", "capacity")] + [FluentReference("usage", "capacity")] const string SiloUsage = "label-silo-usage"; [ObjectCreator.UseCtor] @@ -30,9 +30,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic siloBar.GetUsed = () => playerResources.Resources; siloBar.TooltipTextCached = new CachedTransform<(float Current, float Capacity), string>(usage => { - return TranslationProvider.GetString( + return FluentProvider.GetString( SiloUsage, - Translation.Arguments("usage", usage.Current, "capacity", usage.Capacity)); + FluentBundle.Arguments("usage", usage.Current, "capacity", usage.Capacity)); }); siloBar.GetBarColor = () => { diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverShroudSelectorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverShroudSelectorLogic.cs index d5517ab410..da8eebf81d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverShroudSelectorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverShroudSelectorLogic.cs @@ -23,22 +23,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic [ChromeLogicArgsHotkeys("CombinedViewKey", "WorldViewKey")] public class ObserverShroudSelectorLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string CameraOptionAllPlayers = "options-shroud-selector.all-players"; - [TranslationReference] + [FluentReference] const string CameraOptionDisableShroud = "options-shroud-selector.disable-shroud"; - [TranslationReference] + [FluentReference] const string CameraOptionOther = "options-shroud-selector.other"; - [TranslationReference] + [FluentReference] const string Players = "label-players"; - [TranslationReference("team")] + [FluentReference("team")] const string TeamNumber = "label-team-name"; - [TranslationReference] + [FluentReference] const string NoTeam = "label-no-team"; readonly CameraOption combined, disableShroud; @@ -104,10 +104,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic var groups = new Dictionary>(); - combined = new CameraOption(this, world, TranslationProvider.GetString(CameraOptionAllPlayers), world.Players.First(p => p.InternalName == "Everyone")); - disableShroud = new CameraOption(this, world, TranslationProvider.GetString(CameraOptionDisableShroud), null); + combined = new CameraOption(this, world, FluentProvider.GetString(CameraOptionAllPlayers), world.Players.First(p => p.InternalName == "Everyone")); + disableShroud = new CameraOption(this, world, FluentProvider.GetString(CameraOptionDisableShroud), null); if (!limitViews) - groups.Add(TranslationProvider.GetString(CameraOptionOther), new List() { combined, disableShroud }); + groups.Add(FluentProvider.GetString(CameraOptionOther), new List() { combined, disableShroud }); teams = world.Players.Where(p => !p.NonCombatant && p.Playable) .Select(p => new CameraOption(this, p)) @@ -120,9 +120,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic foreach (var t in teams) { totalPlayers += t.Count(); - var label = noTeams ? TranslationProvider.GetString(Players) : t.Key > 0 - ? TranslationProvider.GetString(TeamNumber, Translation.Arguments("team", t.Key)) - : TranslationProvider.GetString(NoTeam); + var label = noTeams ? FluentProvider.GetString(Players) : t.Key > 0 + ? FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", t.Key)) + : FluentProvider.GetString(NoTeam); groups.Add(label, t); } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs index 87d8273f9d..d9361c2096 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs @@ -35,37 +35,37 @@ namespace OpenRA.Mods.Common.Widgets.Logic "StatisticsArmyGraphKey")] public class ObserverStatsLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string InformationNone = "options-observer-stats.none"; - [TranslationReference] + [FluentReference] const string Basic = "options-observer-stats.basic"; - [TranslationReference] + [FluentReference] const string Economy = "options-observer-stats.economy"; - [TranslationReference] + [FluentReference] const string Production = "options-observer-stats.production"; - [TranslationReference] + [FluentReference] const string SupportPowers = "options-observer-stats.support-powers"; - [TranslationReference] + [FluentReference] const string Combat = "options-observer-stats.combat"; - [TranslationReference] + [FluentReference] const string Army = "options-observer-stats.army"; - [TranslationReference] + [FluentReference] const string EarningsGraph = "options-observer-stats.earnings-graph"; - [TranslationReference] + [FluentReference] const string ArmyGraph = "options-observer-stats.army-graph"; - [TranslationReference("team")] + [FluentReference("team")] const string TeamNumber = "label-team-name"; - [TranslationReference] + [FluentReference] const string NoTeam = "label-no-team"; readonly ContainerWidget basicStatsHeaders; @@ -155,10 +155,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic var statsDropDown = widget.Get("STATS_DROPDOWN"); StatsDropDownOption CreateStatsOption(string title, ObserverStatsPanel panel, ScrollItemWidget template, Action a) { - title = TranslationProvider.GetString(title); + title = FluentProvider.GetString(title); return new StatsDropDownOption { - Title = TranslationProvider.GetString(title), + Title = FluentProvider.GetString(title), IsSelected = () => activePanel == panel, OnClick = () => { @@ -179,11 +179,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic { new() { - Title = TranslationProvider.GetString(InformationNone), + Title = FluentProvider.GetString(InformationNone), IsSelected = () => activePanel == ObserverStatsPanel.None, OnClick = () => { - var informationNone = TranslationProvider.GetString(InformationNone); + var informationNone = FluentProvider.GetString(InformationNone); statsDropDown.GetText = () => informationNone; playerStatsPanel.Visible = false; ClearStats(); @@ -286,8 +286,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic tt.IgnoreMouseOver = true; var teamLabel = tt.Get("TEAM"); - var teamText = team.Key > 0 ? TranslationProvider.GetString(TeamNumber, Translation.Arguments("team", team.Key)) - : TranslationProvider.GetString(NoTeam); + var teamText = team.Key > 0 ? FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", team.Key)) + : FluentProvider.GetString(NoTeam); teamLabel.GetText = () => teamText; tt.Bounds.Width = teamLabel.Bounds.Width = Game.Renderer.Fonts[tt.Font].Measure(teamText).X; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs index 66d8f64b4c..dbc120e988 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ProductionTooltipLogic.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class ProductionTooltipLogic : ChromeLogic { - [TranslationReference("prequisites")] + [FluentReference("prequisites")] const string Requires = "label-requires"; [ObjectCreator.UseCtor] @@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic return; var tooltip = actor.TraitInfos().FirstOrDefault(info => info.EnabledByDefault); - var name = tooltip != null ? TranslationProvider.GetString(tooltip.Name) : actor.Name; + var name = tooltip != null ? FluentProvider.GetString(tooltip.Name) : actor.Name; var buildable = actor.TraitInfo(); var cost = 0; @@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var requiresSize = int2.Zero; if (prereqs.Count > 0) { - var requiresText = TranslationProvider.GetString(Requires, Translation.Arguments("prequisites", prereqs.JoinWith(", "))); + var requiresText = FluentProvider.GetString(Requires, FluentBundle.Arguments("prequisites", prereqs.JoinWith(", "))); requiresLabel.GetText = () => requiresText; requiresSize = requiresFont.Measure(requiresText); requiresLabel.Visible = true; @@ -146,7 +146,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic costLabel.GetColor = () => pr.GetCashAndResources() >= cost ? Color.White : Color.Red; var costSize = font.Measure(costText); - var desc = string.IsNullOrEmpty(buildable.Description) ? "" : TranslationProvider.GetString(buildable.Description); + var desc = string.IsNullOrEmpty(buildable.Description) ? "" : FluentProvider.GetString(buildable.Description); descLabel.GetText = () => desc; var descSize = descFont.Measure(desc); descLabel.Bounds.Width = descSize.X; @@ -180,7 +180,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var actorTooltip = ai.TraitInfos().FirstOrDefault(info => info.EnabledByDefault); if (actorTooltip != null) - return TranslationProvider.GetString(actorTooltip.Name); + return FluentProvider.GetString(actorTooltip.Name); } return a; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/WorldTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/WorldTooltipLogic.cs index bd6644955d..397a83dff7 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/WorldTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/WorldTooltipLogic.cs @@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class WorldTooltipLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string UnrevealedTerrain = "label-unrevealed-terrain"; [ObjectCreator.UseCtor] @@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var extraHeightOnDouble = extras.Bounds.Y; var extraHeightOnSingle = extraHeightOnDouble - (doubleHeight - singleHeight); - var unrevealedTerrain = TranslationProvider.GetString(UnrevealedTerrain); + var unrevealedTerrain = FluentProvider.GetString(UnrevealedTerrain); tooltipContainer.BeforeRender = () => { diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs index 54f08d4b6f..e9c5ef6aa0 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs @@ -24,37 +24,37 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class DownloadPackageLogic : ChromeLogic { - [TranslationReference("title")] + [FluentReference("title")] const string Downloading = "label-downloading"; - [TranslationReference] + [FluentReference] const string FetchingMirrorList = "label-fetching-mirror-list"; - [TranslationReference] + [FluentReference] const string UnknownHost = "label-unknown-host"; - [TranslationReference("host", "received", "suffix")] + [FluentReference("host", "received", "suffix")] const string DownloadingFrom = "label-downloading-from"; - [TranslationReference("host", "received", "total", "suffix", "progress")] + [FluentReference("host", "received", "total", "suffix", "progress")] const string DownloadingFromProgress = "label-downloading-from-progress"; - [TranslationReference] + [FluentReference] const string VerifyingArchive = "label-verifying-archive"; - [TranslationReference] + [FluentReference] const string ArchiveValidationFailed = "label-archive-validation-failed"; - [TranslationReference] + [FluentReference] const string Extracting = "label-extracting-archive"; - [TranslationReference("entry")] + [FluentReference("entry")] const string ExtractingEntry = "label-extracting-archive-entry"; - [TranslationReference] + [FluentReference] const string ArchiveExtractionFailed = "label-archive-extraction-failed"; - [TranslationReference] + [FluentReference] const string MirrorSelectionFailed = "label-mirror-selection-failed"; static readonly string[] SizeSuffixes = { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; @@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var status = new CachedTransform(s => WidgetUtils.TruncateText(s, statusLabel.Bounds.Width, statusFont)); statusLabel.GetText = () => status.Update(getStatusText()); - var text = TranslationProvider.GetString(Downloading, Translation.Arguments("title", download.Title)); + var text = FluentProvider.GetString(Downloading, FluentBundle.Arguments("title", download.Title)); panel.Get("TITLE").GetText = () => text; ShowDownloadDialog(); @@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic void ShowDownloadDialog() { - getStatusText = () => TranslationProvider.GetString(FetchingMirrorList); + getStatusText = () => FluentProvider.GetString(FetchingMirrorList); progressBar.Indeterminate = true; var retryButton = panel.Get("RETRY_BUTTON"); @@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var dataTotal = 0.0f; var mag = 0; var dataSuffix = ""; - var host = downloadHost ?? TranslationProvider.GetString(UnknownHost); + var host = downloadHost ?? FluentProvider.GetString(UnknownHost); if (total < 0) { @@ -116,8 +116,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic dataReceived = read / (float)(1L << (mag * 10)); dataSuffix = SizeSuffixes[mag]; - getStatusText = () => TranslationProvider.GetString(DownloadingFrom, - Translation.Arguments("host", host, "received", $"{dataReceived:0.00}", "suffix", dataSuffix)); + getStatusText = () => FluentProvider.GetString(DownloadingFrom, + FluentBundle.Arguments("host", host, "received", $"{dataReceived:0.00}", "suffix", dataSuffix)); progressBar.Indeterminate = true; } else @@ -127,8 +127,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic dataReceived = read / (float)(1L << (mag * 10)); dataSuffix = SizeSuffixes[mag]; - getStatusText = () => TranslationProvider.GetString(DownloadingFromProgress, - Translation.Arguments("host", host, "received", $"{dataReceived:0.00}", "total", $"{dataTotal:0.00}", + getStatusText = () => FluentProvider.GetString(DownloadingFromProgress, + FluentBundle.Arguments("host", host, "received", $"{dataReceived:0.00}", "total", $"{dataTotal:0.00}", "suffix", dataSuffix, "progress", progressPercentage)); progressBar.Indeterminate = false; } @@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic void OnError(string s) => Game.RunAfterTick(() => { - var host = downloadHost ?? TranslationProvider.GetString(UnknownHost); + var host = downloadHost ?? FluentProvider.GetString(UnknownHost); Log.Write("install", $"Download from {host} failed: " + s); progressBar.Indeterminate = false; @@ -184,7 +184,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic // Validate integrity if (!string.IsNullOrEmpty(download.SHA1)) { - getStatusText = () => TranslationProvider.GetString(VerifyingArchive); + getStatusText = () => FluentProvider.GetString(VerifyingArchive); progressBar.Indeterminate = true; var archiveValid = false; @@ -206,13 +206,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (!archiveValid) { - OnError(TranslationProvider.GetString(ArchiveValidationFailed)); + OnError(FluentProvider.GetString(ArchiveValidationFailed)); return; } } // Automatically extract - getStatusText = () => TranslationProvider.GetString(Extracting); + getStatusText = () => FluentProvider.GetString(Extracting); progressBar.Indeterminate = true; var extracted = new List(); @@ -232,7 +232,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic continue; } - OnExtractProgress(TranslationProvider.GetString(ExtractingEntry, Translation.Arguments("entry", kv.Value))); + OnExtractProgress(FluentProvider.GetString(ExtractingEntry, FluentBundle.Arguments("entry", kv.Value))); Log.Write("install", "Extracting " + kv.Value); var targetPath = Platform.ResolvePath(kv.Key); Directory.CreateDirectory(Path.GetDirectoryName(targetPath)); @@ -263,7 +263,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic File.Delete(f); } - OnError(TranslationProvider.GetString(ArchiveExtractionFailed)); + OnError(FluentProvider.GetString(ArchiveExtractionFailed)); } } catch (Exception e) @@ -296,7 +296,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { Log.Write("install", "Mirror selection failed with error:"); Log.Write("install", e.ToString()); - OnError(TranslationProvider.GetString(MirrorSelectionFailed)); + OnError(FluentProvider.GetString(MirrorSelectionFailed)); } }); } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromSourceLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromSourceLogic.cs index 44f385550a..d2f2799f6e 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromSourceLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromSourceLogic.cs @@ -22,61 +22,61 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class InstallFromSourceLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string DetectingSources = "label-detecting-sources"; - [TranslationReference] + [FluentReference] const string CheckingSources = "label-checking-sources"; - [TranslationReference("title")] + [FluentReference("title")] const string SearchingSourceFor = "label-searching-source-for"; - [TranslationReference] + [FluentReference] const string ContentPackageInstallation = "label-content-package-installation"; - [TranslationReference] + [FluentReference] const string GameSources = "label-game-sources"; - [TranslationReference] + [FluentReference] const string DigitalInstalls = "label-digital-installs"; - [TranslationReference] + [FluentReference] const string GameContentNotFound = "label-game-content-not-found"; - [TranslationReference] + [FluentReference] const string AlternativeContentSources = "label-alternative-content-sources"; - [TranslationReference] + [FluentReference] const string InstallingContent = "label-installing-content"; - [TranslationReference("filename")] + [FluentReference("filename")] public const string CopyingFilename = "label-copying-filename"; - [TranslationReference("filename", "progress")] + [FluentReference("filename", "progress")] public const string CopyingFilenameProgress = "label-copying-filename-progress"; - [TranslationReference] + [FluentReference] const string InstallationFailed = "label-installation-failed"; - [TranslationReference] + [FluentReference] const string CheckInstallLog = "label-check-install-log"; - [TranslationReference("filename")] + [FluentReference("filename")] public const string Extracing = "label-extracting-filename"; - [TranslationReference("filename", "progress")] + [FluentReference("filename", "progress")] public const string ExtractingProgress = "label-extracting-filename-progress"; - [TranslationReference] + [FluentReference] public const string Continue = "button-continue"; - [TranslationReference] + [FluentReference] const string Cancel = "button-cancel"; - [TranslationReference] + [FluentReference] const string Retry = "button-retry"; - [TranslationReference] + [FluentReference] const string Back = "button-back"; // Hide percentage indicators for files smaller than 25 MB @@ -160,15 +160,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic void DetectContentSources() { - var message = TranslationProvider.GetString(DetectingSources); - ShowProgressbar(TranslationProvider.GetString(CheckingSources), () => message); + var message = FluentProvider.GetString(DetectingSources); + ShowProgressbar(FluentProvider.GetString(CheckingSources), () => message); ShowBackRetry(DetectContentSources); new Task(() => { foreach (var kv in sources) { - message = TranslationProvider.GetString(SearchingSourceFor, Translation.Arguments("title", kv.Value.Title)); + message = FluentProvider.GetString(SearchingSourceFor, FluentBundle.Arguments("title", kv.Value.Title)); var sourceResolver = kv.Value.ObjectCreator.CreateObject($"{kv.Value.Type.Value}SourceResolver"); @@ -188,7 +188,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { Game.RunAfterTick(() => { - ShowList(kv.Value, TranslationProvider.GetString(ContentPackageInstallation)); + ShowList(kv.Value, FluentProvider.GetString(ContentPackageInstallation)); ShowContinueCancel(() => InstallFromSource(path, kv.Value)); }); @@ -220,14 +220,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic var options = new Dictionary>(); if (gameSources.Count != 0) - options.Add(TranslationProvider.GetString(GameSources), gameSources); + options.Add(FluentProvider.GetString(GameSources), gameSources); if (digitalInstalls.Count != 0) - options.Add(TranslationProvider.GetString(DigitalInstalls), digitalInstalls); + options.Add(FluentProvider.GetString(DigitalInstalls), digitalInstalls); Game.RunAfterTick(() => { - ShowList(TranslationProvider.GetString(GameContentNotFound), TranslationProvider.GetString(AlternativeContentSources), options); + ShowList(FluentProvider.GetString(GameContentNotFound), FluentProvider.GetString(AlternativeContentSources), options); ShowBackRetry(DetectContentSources); }); }).Start(); @@ -236,7 +236,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic void InstallFromSource(string path, ModContent.ModSource modSource) { var message = ""; - ShowProgressbar(TranslationProvider.GetString(InstallingContent), () => message); + ShowProgressbar(FluentProvider.GetString(InstallingContent), () => message); ShowDisabledCancel(); new Task(() => @@ -292,7 +292,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic Game.RunAfterTick(() => { - ShowMessage(TranslationProvider.GetString(InstallationFailed), TranslationProvider.GetString(CheckInstallLog)); + ShowMessage(FluentProvider.GetString(InstallationFailed), FluentProvider.GetString(CheckInstallLog)); ShowBackRetry(() => InstallFromSource(path, modSource)); }); } @@ -398,12 +398,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic void ShowContinueCancel(Action continueAction) { primaryButton.OnClick = continueAction; - var primaryButtonText = TranslationProvider.GetString(Continue); + var primaryButtonText = FluentProvider.GetString(Continue); primaryButton.GetText = () => primaryButtonText; primaryButton.Visible = true; secondaryButton.OnClick = Ui.CloseWindow; - var secondaryButtonText = TranslationProvider.GetString(Cancel); + var secondaryButtonText = FluentProvider.GetString(Cancel); secondaryButton.GetText = () => secondaryButtonText; secondaryButton.Visible = true; secondaryButton.Disabled = false; @@ -413,12 +413,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic void ShowBackRetry(Action retryAction) { primaryButton.OnClick = retryAction; - var primaryButtonText = TranslationProvider.GetString(Retry); + var primaryButtonText = FluentProvider.GetString(Retry); primaryButton.GetText = () => primaryButtonText; primaryButton.Visible = true; secondaryButton.OnClick = Ui.CloseWindow; - var secondaryButtonText = TranslationProvider.GetString(Back); + var secondaryButtonText = FluentProvider.GetString(Back); secondaryButton.GetText = () => secondaryButtonText; secondaryButton.Visible = true; secondaryButton.Disabled = false; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentLogic.cs index b853c6dbde..fcd6ba7b7c 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentLogic.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class ModContentLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string ManualInstall = "button-manual-install"; readonly ModContent content; @@ -144,7 +144,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic requiresSourceWidget.IsVisible = () => !installed && !downloadEnabled; if (!isSourceAvailable) { - var manualInstall = TranslationProvider.GetString(ManualInstall); + var manualInstall = FluentProvider.GetString(ManualInstall); requiresSourceWidget.GetText = () => manualInstall; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentPromptLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentPromptLogic.cs index 4cb10e51ec..0499f535a5 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentPromptLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/ModContentPromptLogic.cs @@ -20,10 +20,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class ModContentPromptLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string Continue = "button-continue"; - [TranslationReference] + [FluentReference] const string Quit = "button-quit"; readonly ModContent content; @@ -35,8 +35,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic this.content = content; CheckRequiredContentInstalled(); - var continueMessage = TranslationProvider.GetString(Continue); - var quitMessage = TranslationProvider.GetString(Quit); + var continueMessage = FluentProvider.GetString(Continue); + var quitMessage = FluentProvider.GetString(Quit); var panel = widget.Get("CONTENT_PROMPT_PANEL"); var headerTemplate = panel.Get("HEADER_TEMPLATE"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/IntroductionPromptLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/IntroductionPromptLogic.cs index 7a34ef5f7b..c4ffaea3f4 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/IntroductionPromptLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/IntroductionPromptLogic.cs @@ -22,10 +22,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic // Increment the version number when adding new stats const int IntroductionVersion = 1; - [TranslationReference] + [FluentReference] const string Classic = "options-control-scheme.classic"; - [TranslationReference] + [FluentReference] const string Modern = "options-control-scheme.modern"; readonly string classic; @@ -43,8 +43,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic var ds = Game.Settings.Graphics; var gs = Game.Settings.Game; - classic = TranslationProvider.GetString(Classic); - modern = TranslationProvider.GetString(Modern); + classic = FluentProvider.GetString(Classic); + modern = FluentProvider.GetString(Modern); var escPressed = false; var nameTextfield = widget.Get("PLAYERNAME"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickClientLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickClientLogic.cs index dac7975d1e..d9f22962dd 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickClientLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickClientLogic.cs @@ -16,13 +16,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic { sealed class KickClientLogic : ChromeLogic { - [TranslationReference("player")] + [FluentReference("player")] const string KickClient = "dialog-kick-client.prompt"; [ObjectCreator.UseCtor] public KickClientLogic(Widget widget, string clientName, Action okPressed, Action cancelPressed) { - var kickMessage = TranslationProvider.GetString(KickClient, Translation.Arguments("player", clientName)); + var kickMessage = FluentProvider.GetString(KickClient, FluentBundle.Arguments("player", clientName)); widget.Get("TITLE").GetText = () => kickMessage; var tempBan = false; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickSpectatorsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickSpectatorsLogic.cs index 02cab7baa0..fec59045b7 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickSpectatorsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/KickSpectatorsLogic.cs @@ -16,13 +16,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic { sealed class KickSpectatorsLogic : ChromeLogic { - [TranslationReference("count")] + [FluentReference("count")] const string KickSpectators = "dialog-kick-spectators.prompt"; [ObjectCreator.UseCtor] public KickSpectatorsLogic(Widget widget, int clientCount, Action okPressed, Action cancelPressed) { - var kickMessage = TranslationProvider.GetString(KickSpectators, Translation.Arguments("count", clientCount)); + var kickMessage = FluentProvider.GetString(KickSpectators, FluentBundle.Arguments("count", clientCount)); widget.Get("TEXT").GetText = () => kickMessage; widget.Get("OK_BUTTON").OnClick = () => diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index 353ad82e6e..af59695673 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -23,40 +23,40 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class LobbyLogic : ChromeLogic, INotificationHandler { - [TranslationReference] + [FluentReference] const string Add = "options-slot-admin.add-bots"; - [TranslationReference] + [FluentReference] const string Remove = "options-slot-admin.remove-bots"; - [TranslationReference] + [FluentReference] const string ConfigureBots = "options-slot-admin.configure-bots"; - [TranslationReference("count")] + [FluentReference("count")] const string NumberTeams = "options-slot-admin.teams-count"; - [TranslationReference] + [FluentReference] const string HumanVsBots = "options-slot-admin.humans-vs-bots"; - [TranslationReference] + [FluentReference] const string FreeForAll = "options-slot-admin.free-for-all"; - [TranslationReference] + [FluentReference] const string ConfigureTeams = "options-slot-admin.configure-teams"; - [TranslationReference] + [FluentReference] const string Back = "button-back"; - [TranslationReference] + [FluentReference] const string TeamChat = "button-team-chat"; - [TranslationReference] + [FluentReference] const string GeneralChat = "button-general-chat"; - [TranslationReference("seconds")] + [FluentReference("seconds")] const string ChatAvailability = "label-chat-availability"; - [TranslationReference] + [FluentReference] const string ChatDisabled = "label-chat-disabled"; static readonly Action DoNothing = () => { }; @@ -282,7 +282,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { new() { - Title = TranslationProvider.GetString(Add), + Title = FluentProvider.GetString(Add), IsSelected = () => false, OnClick = () => { @@ -301,7 +301,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { botOptions.Add(new DropDownOption() { - Title = TranslationProvider.GetString(Remove), + Title = FluentProvider.GetString(Remove), IsSelected = () => false, OnClick = () => { @@ -315,7 +315,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic }); } - options.Add(TranslationProvider.GetString(ConfigureBots), botOptions); + options.Add(FluentProvider.GetString(ConfigureBots), botOptions); } var teamCount = (orderManager.LobbyInfo.Slots.Count(s => !s.Value.LockTeam && orderManager.LobbyInfo.ClientInSlot(s.Key) != null) + 1) / 2; @@ -323,7 +323,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var teamOptions = Enumerable.Range(2, teamCount - 1).Reverse().Select(d => new DropDownOption { - Title = TranslationProvider.GetString(NumberTeams, Translation.Arguments("count", d)), + Title = FluentProvider.GetString(NumberTeams, FluentBundle.Arguments("count", d)), IsSelected = () => false, OnClick = () => orderManager.IssueOrder(Order.Command($"assignteams {d}")) }).ToList(); @@ -332,7 +332,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { teamOptions.Add(new DropDownOption { - Title = TranslationProvider.GetString(HumanVsBots), + Title = FluentProvider.GetString(HumanVsBots), IsSelected = () => false, OnClick = () => orderManager.IssueOrder(Order.Command("assignteams 1")) }); @@ -340,12 +340,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic teamOptions.Add(new DropDownOption { - Title = TranslationProvider.GetString(FreeForAll), + Title = FluentProvider.GetString(FreeForAll), IsSelected = () => false, OnClick = () => orderManager.IssueOrder(Order.Command("assignteams 0")) }); - options.Add(TranslationProvider.GetString(ConfigureTeams), teamOptions); + options.Add(FluentProvider.GetString(ConfigureTeams), teamOptions); } ScrollItemWidget SetupItem(DropDownOption option, ScrollItemWidget template) @@ -483,7 +483,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (skirmishMode) { - var disconnectButtonText = TranslationProvider.GetString(Back); + var disconnectButtonText = FluentProvider.GetString(Back); disconnectButton.GetText = () => disconnectButtonText; } @@ -497,8 +497,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic } var chatMode = lobby.Get("CHAT_MODE"); - var team = TranslationProvider.GetString(TeamChat); - var all = TranslationProvider.GetString(GeneralChat); + var team = FluentProvider.GetString(TeamChat); + var all = FluentProvider.GetString(GeneralChat); chatMode.GetText = () => teamChat ? team : all; chatMode.OnClick = () => teamChat ^= true; chatMode.IsDisabled = () => disableTeamChat || !chatEnabled; @@ -539,8 +539,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic chatTextField.OnEscKey = _ => chatTextField.YieldKeyboardFocus(); - chatAvailableIn = new CachedTransform(x => TranslationProvider.GetString(ChatAvailability, Translation.Arguments("seconds", x))); - chatDisabled = TranslationProvider.GetString(ChatDisabled); + chatAvailableIn = new CachedTransform(x => FluentProvider.GetString(ChatAvailability, FluentBundle.Arguments("seconds", x))); + chatDisabled = FluentProvider.GetString(ChatDisabled); lobbyChatPanel = lobby.Get("CHAT_DISPLAY"); lobbyChatPanel.RemoveChildren(); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs index e674b0186f..611e9fd60d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class LobbyOptionsLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string NotAvailable = "label-not-available"; readonly ScrollPanelWidget panel; @@ -146,7 +146,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var getOptionLabel = new CachedTransform(id => { if (id == null || !option.Values.TryGetValue(id, out var value)) - return TranslationProvider.GetString(NotAvailable); + return FluentProvider.GetString(NotAvailable); return value; }); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs index d4c7c49849..1f206a9b0d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs @@ -24,19 +24,19 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public static class LobbyUtils { - [TranslationReference] + [FluentReference] const string Open = "options-lobby-slot.open"; - [TranslationReference] + [FluentReference] const string Closed = "options-lobby-slot.closed"; - [TranslationReference] + [FluentReference] const string Bots = "options-lobby-slot.bots"; - [TranslationReference] + [FluentReference] const string BotsDisabled = "options-lobby-slot.bots-disabled"; - [TranslationReference] + [FluentReference] const string Slot = "options-lobby-slot.slot"; sealed class SlotDropDownOption @@ -56,12 +56,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic public static void ShowSlotDropDown(DropDownButtonWidget dropdown, Session.Slot slot, Session.Client client, OrderManager orderManager, MapPreview map, ModData modData) { - var open = TranslationProvider.GetString(Open); - var closed = TranslationProvider.GetString(Closed); + var open = FluentProvider.GetString(Open); + var closed = FluentProvider.GetString(Closed); var options = new Dictionary> { { - TranslationProvider.GetString(Slot), new List + FluentProvider.GetString(Slot), new List { new(open, "slot_open " + slot.PlayerReference, () => !slot.Closed && client == null), new(closed, "slot_close " + slot.PlayerReference, () => slot.Closed) @@ -75,13 +75,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic foreach (var b in map.PlayerActorInfo.TraitInfos()) { var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin); - bots.Add(new SlotDropDownOption(TranslationProvider.GetString(b.Name), + bots.Add(new SlotDropDownOption(FluentProvider.GetString(b.Name), $"slot_bot {slot.PlayerReference} {botController.Index} {b.Type}", () => client != null && client.Bot == b.Type)); } } - options.Add(bots.Count > 0 ? TranslationProvider.GetString(Bots) : TranslationProvider.GetString(BotsDisabled), bots); + options.Add(bots.Count > 0 ? FluentProvider.GetString(Bots) : FluentProvider.GetString(BotsDisabled), bots); ScrollItemWidget SetupItem(SlotDropDownOption o, ScrollItemWidget itemTemplate) { @@ -222,14 +222,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic var faction = factions[factionId]; var label = item.Get("LABEL"); - var labelText = WidgetUtils.TruncateText(TranslationProvider.GetString(faction.Name), label.Bounds.Width, Game.Renderer.Fonts[label.Font]); + var labelText = WidgetUtils.TruncateText(FluentProvider.GetString(faction.Name), label.Bounds.Width, Game.Renderer.Fonts[label.Font]); label.GetText = () => labelText; var flag = item.Get("FLAG"); flag.GetImageCollection = () => "flags"; flag.GetImageName = () => factionId; - var description = faction.Description != null ? TranslationProvider.GetString(faction.Description) : null; + var description = faction.Description != null ? FluentProvider.GetString(faction.Description) : null; var (text, desc) = SplitOnFirstToken(description); item.GetTooltipText = () => text; item.GetTooltipDesc = () => desc; @@ -238,7 +238,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } var options = factions.Where(f => f.Value.Selectable).GroupBy(f => f.Value.Side) - .ToDictionary(g => g.Key != null ? TranslationProvider.GetString(g.Key) : "", g => g.Select(f => TranslationProvider.GetString(f.Key))); + .ToDictionary(g => g.Key != null ? FluentProvider.GetString(g.Key) : "", g => g.Select(f => FluentProvider.GetString(f.Key))); dropdown.ShowDropDown("FACTION_DROPDOWN_TEMPLATE", 154, options, SetupItem); } @@ -430,7 +430,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var label = parent.Get("NAME"); label.IsVisible = () => true; var font = Game.Renderer.Fonts[label.Font]; - var name = c.IsBot ? TranslationProvider.GetString(c.Name) : c.Name; + var name = c.IsBot ? FluentProvider.GetString(c.Name) : c.Name; var text = WidgetUtils.TruncateText(name, label.Bounds.Width, font); label.GetText = () => text; @@ -448,10 +448,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic WidgetUtils.TruncateText(name, slot.Bounds.Width - slot.Bounds.Height - slot.LeftMargin - slot.RightMargin, Game.Renderer.Fonts[slot.Font])); - var closed = TranslationProvider.GetString(Closed); - var open = TranslationProvider.GetString(Open); + var closed = FluentProvider.GetString(Closed); + var open = FluentProvider.GetString(Open); slot.GetText = () => truncated.Update(c != null ? - c.IsBot ? TranslationProvider.GetString(c.Name) : c.Name + c.IsBot ? FluentProvider.GetString(c.Name) : c.Name : s.Closed ? closed : open); slot.OnMouseDown = _ => ShowSlotDropDown(slot, s, c, orderManager, map, modData); @@ -465,8 +465,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic var name = parent.Get("NAME"); name.IsVisible = () => true; name.GetText = () => c != null ? c.Name : s.Closed - ? TranslationProvider.GetString(Closed) - : TranslationProvider.GetString(Open); + ? FluentProvider.GetString(Closed) + : FluentProvider.GetString(Open); // Ensure Slot selector (if present) is hidden HideChildWidget(parent, "SLOT_OPTIONS"); @@ -564,7 +564,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic dropdown.IsDisabled = () => s.LockFaction || orderManager.LocalClient.IsReady; dropdown.OnMouseDown = _ => ShowFactionDropDown(dropdown, c, orderManager, factions); - var description = factions[c.Faction].Description != null ? TranslationProvider.GetString(factions[c.Faction].Description) : null; + var description = factions[c.Faction].Description != null ? FluentProvider.GetString(factions[c.Faction].Description) : null; var (text, desc) = SplitOnFirstToken(description); dropdown.GetTooltipText = () => text; dropdown.GetTooltipDesc = () => desc; @@ -577,7 +577,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var factionName = parent.Get("FACTIONNAME"); var font = Game.Renderer.Fonts[factionName.Font]; var truncated = new CachedTransform(clientFaction => - WidgetUtils.TruncateText(TranslationProvider.GetString(factions[clientFaction].Name), factionName.Bounds.Width, font)); + WidgetUtils.TruncateText(FluentProvider.GetString(factions[clientFaction].Name), factionName.Bounds.Width, font)); factionName.GetText = () => truncated.Update(c.Faction); var factionFlag = parent.Get("FACTIONFLAG"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/MapPreviewLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/MapPreviewLogic.cs index 8c2c1c2fb4..d4943a1ab0 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/MapPreviewLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/MapPreviewLogic.cs @@ -20,22 +20,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class MapPreviewLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string Connecting = "label-connecting"; - [TranslationReference("size")] + [FluentReference("size")] const string Downloading = "label-downloading-map"; - [TranslationReference("size", "progress")] + [FluentReference("size", "progress")] const string DownloadingPercentage = "label-downloading-map-progress"; - [TranslationReference] + [FluentReference] const string RetryInstall = "button-retry-install"; - [TranslationReference] + [FluentReference] const string RetrySearch = "button-retry-search"; - [TranslationReference("author")] + [FluentReference("author")] const string CreatedBy = "label-created-by"; readonly int blinkTickLength = 10; @@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } var authorCache = new CachedTransform( - text => TranslationProvider.GetString(CreatedBy, Translation.Arguments("author", text))); + text => FluentProvider.GetString(CreatedBy, FluentBundle.Arguments("author", text))); Widget SetupAuthorAndMapType(Widget parent) { @@ -165,13 +165,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var (map, _) = getMap(); if (map.DownloadBytes == 0) - return TranslationProvider.GetString(Connecting); + return FluentProvider.GetString(Connecting); // Server does not provide the total file length. if (map.DownloadPercentage == 0) - return TranslationProvider.GetString(Downloading, Translation.Arguments("size", map.DownloadBytes / 1024)); + return FluentProvider.GetString(Downloading, FluentBundle.Arguments("size", map.DownloadBytes / 1024)); - return TranslationProvider.GetString(DownloadingPercentage, Translation.Arguments("size", map.DownloadBytes / 1024, "progress", map.DownloadPercentage)); + return FluentProvider.GetString(DownloadingPercentage, FluentBundle.Arguments("size", map.DownloadBytes / 1024, "progress", map.DownloadPercentage)); }; return parent; @@ -198,8 +198,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic modData.MapCache.QueryRemoteMapDetails(mapRepository, new[] { map.Uid }); }; - var retryInstall = TranslationProvider.GetString(RetryInstall); - var retrySearch = TranslationProvider.GetString(RetrySearch); + var retryInstall = FluentProvider.GetString(RetryInstall); + var retrySearch = FluentProvider.GetString(RetrySearch); retryButton.GetText = () => getMap().Map.Status == MapStatus.DownloadError ? retryInstall : retrySearch; var previewLarge = SetupMapPreview(widget.Get("MAP_LARGE")); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/SpawnSelectorTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/SpawnSelectorTooltipLogic.cs index ea8cb2ec23..2f127c45eb 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/SpawnSelectorTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/SpawnSelectorTooltipLogic.cs @@ -18,13 +18,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class SpawnSelectorTooltipLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string DisabledSpawn = "label-disabled-spawn"; - [TranslationReference] + [FluentReference] const string AvailableSpawn = "label-available-spawn"; - [TranslationReference("team")] + [FluentReference("team")] const string TeamNumber = "label-team-name"; readonly CachedTransform teamMessage; @@ -49,9 +49,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic var labelText = ""; string playerFaction = null; var playerTeam = -1; - teamMessage = new CachedTransform(t => TranslationProvider.GetString(TeamNumber, Translation.Arguments("team", t))); - var disabledSpawn = TranslationProvider.GetString(DisabledSpawn); - var availableSpawn = TranslationProvider.GetString(AvailableSpawn); + teamMessage = new CachedTransform(t => FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", t))); + var disabledSpawn = FluentProvider.GetString(DisabledSpawn); + var availableSpawn = FluentProvider.GetString(AvailableSpawn); tooltipContainer.BeforeRender = () => { diff --git a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs index e1a98448fd..19dcc3f991 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs @@ -23,16 +23,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class MainMenuLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string LoadingNews = "label-loading-news"; - [TranslationReference("message")] + [FluentReference("message")] const string NewsRetrivalFailed = "label-news-retrieval-failed"; - [TranslationReference("message")] + [FluentReference("message")] const string NewsParsingFailed = "label-news-parsing-failed"; - [TranslationReference("author", "datetime")] + [FluentReference("author", "datetime")] const string AuthorDateTime = "label-author-datetime"; protected enum MenuType { Main, Singleplayer, Extras, MapEditor, StartupPrompts, None } @@ -234,7 +234,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic newsPanel.RemoveChild(newsTemplate); newsStatus = newsPanel.Get("NEWS_STATUS"); - SetNewsStatus(TranslationProvider.GetString(LoadingNews)); + SetNewsStatus(FluentProvider.GetString(LoadingNews)); } Game.OnRemoteDirectConnect += OnRemoteDirectConnect; @@ -346,7 +346,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic catch (Exception e) { Game.RunAfterTick(() => // run on the main thread - SetNewsStatus(TranslationProvider.GetString(NewsRetrivalFailed, Translation.Arguments("message", e.Message)))); + SetNewsStatus(FluentProvider.GetString(NewsRetrivalFailed, FluentBundle.Arguments("message", e.Message)))); } }); } @@ -417,7 +417,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } catch (Exception ex) { - SetNewsStatus(TranslationProvider.GetString(NewsParsingFailed, Translation.Arguments("message", ex.Message))); + SetNewsStatus(FluentProvider.GetString(NewsParsingFailed, FluentBundle.Arguments("message", ex.Message))); } return null; @@ -438,7 +438,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic titleLabel.GetText = () => item.Title; var authorDateTimeLabel = newsItem.Get("AUTHOR_DATETIME"); - var authorDateTime = TranslationProvider.GetString(AuthorDateTime, Translation.Arguments( + var authorDateTime = FluentProvider.GetString(AuthorDateTime, FluentBundle.Arguments( "author", item.Author, "datetime", item.DateTime.ToLocalTime().ToString(CultureInfo.CurrentCulture))); diff --git a/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs index 23a560d153..59750890ea 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs @@ -19,67 +19,67 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class MapChooserLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string AllMaps = "label-all-maps"; - [TranslationReference] + [FluentReference] const string NoMatches = "label-no-matches"; - [TranslationReference("players")] + [FluentReference("players")] const string Players = "label-player-count"; - [TranslationReference("author")] + [FluentReference("author")] const string CreatedBy = "label-created-by"; - [TranslationReference] + [FluentReference] const string MapSizeHuge = "label-map-size-huge"; - [TranslationReference] + [FluentReference] const string MapSizeLarge = "label-map-size-large"; - [TranslationReference] + [FluentReference] const string MapSizeMedium = "label-map-size-medium"; - [TranslationReference] + [FluentReference] const string MapSizeSmall = "label-map-size-small"; - [TranslationReference("count")] + [FluentReference("count")] const string MapSearchingCount = "label-map-searching-count"; - [TranslationReference("count")] + [FluentReference("count")] const string MapUnavailableCount = "label-map-unavailable-count"; - [TranslationReference("map")] + [FluentReference("map")] const string MapDeletionFailed = "notification-map-deletion-failed"; - [TranslationReference] + [FluentReference] const string DeleteMapTitle = "dialog-delete-map.title"; - [TranslationReference("title")] + [FluentReference("title")] const string DeleteMapPrompt = "dialog-delete-map.prompt"; - [TranslationReference] + [FluentReference] const string DeleteMapAccept = "dialog-delete-map.confirm"; - [TranslationReference] + [FluentReference] const string DeleteAllMapsTitle = "dialog-delete-all-maps.title"; - [TranslationReference] + [FluentReference] const string DeleteAllMapsPrompt = "dialog-delete-all-maps.prompt"; - [TranslationReference] + [FluentReference] const string DeleteAllMapsAccept = "dialog-delete-all-maps.confirm"; - [TranslationReference] + [FluentReference] const string OrderMapsByPlayers = "options-order-maps.player-count"; - [TranslationReference] + [FluentReference] const string OrderMapsByTitle = "options-order-maps.title"; - [TranslationReference] + [FluentReference] const string OrderMapsByDate = "options-order-maps.date"; - [TranslationReference] + [FluentReference] const string OrderMapsBySize = "options-order-maps.size"; readonly string allMaps; @@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic this.onSelect = onSelect; this.remoteMapPool = remoteMapPool; - allMaps = TranslationProvider.GetString(AllMaps); + allMaps = FluentProvider.GetString(AllMaps); var approving = new Action(() => { @@ -205,9 +205,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic var remoteMapText = new CachedTransform<(int Searching, int Unavailable), string>(counts => { if (counts.Searching > 0) - return TranslationProvider.GetString(MapSearchingCount, Translation.Arguments("count", counts.Searching)); + return FluentProvider.GetString(MapSearchingCount, FluentBundle.Arguments("count", counts.Searching)); - return TranslationProvider.GetString(MapUnavailableCount, Translation.Arguments("count", counts.Unavailable)); + return FluentProvider.GetString(MapUnavailableCount, FluentBundle.Arguments("count", counts.Unavailable)); }); remoteMapLabel.IsVisible = () => remoteMapPool != null && (remoteSearching > 0 || remoteUnavailable > 0); @@ -359,7 +359,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var item = categories.FirstOrDefault(m => m.Category == category); if (item == default((string, int))) - item.Category = TranslationProvider.GetString(NoMatches); + item.Category = FluentProvider.GetString(NoMatches); return ShowItem(item); }; @@ -372,14 +372,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (orderByDropdown == null) return; - var orderByPlayer = TranslationProvider.GetString(OrderMapsByPlayers); + var orderByPlayer = FluentProvider.GetString(OrderMapsByPlayers); var orderByDict = new Dictionary>() { { orderByPlayer, m => m.PlayerCount }, - { TranslationProvider.GetString(OrderMapsByTitle), null }, - { TranslationProvider.GetString(OrderMapsByDate), m => -m.ModifiedDate.Ticks }, - { TranslationProvider.GetString(OrderMapsBySize), m => m.Bounds.Width * m.Bounds.Height }, + { FluentProvider.GetString(OrderMapsByTitle), null }, + { FluentProvider.GetString(OrderMapsByDate), m => -m.ModifiedDate.Ticks }, + { FluentProvider.GetString(OrderMapsBySize), m => m.Bounds.Width * m.Bounds.Height }, }; orderByFunc = orderByDict[orderByPlayer]; @@ -458,23 +458,23 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (type != null) details = type + " "; - details += TranslationProvider.GetString(Players, Translation.Arguments("players", preview.PlayerCount)); + details += FluentProvider.GetString(Players, FluentBundle.Arguments("players", preview.PlayerCount)); detailsWidget.GetText = () => details; } var authorWidget = item.GetOrNull("AUTHOR"); if (authorWidget != null && !string.IsNullOrEmpty(preview.Author)) - WidgetUtils.TruncateLabelToTooltip(authorWidget, TranslationProvider.GetString(CreatedBy, Translation.Arguments("author", preview.Author))); + WidgetUtils.TruncateLabelToTooltip(authorWidget, FluentProvider.GetString(CreatedBy, FluentBundle.Arguments("author", preview.Author))); var sizeWidget = item.GetOrNull("SIZE"); if (sizeWidget != null) { var size = preview.Bounds.Width + "x" + preview.Bounds.Height; var numberPlayableCells = preview.Bounds.Width * preview.Bounds.Height; - if (numberPlayableCells >= 120 * 120) size += " " + TranslationProvider.GetString(MapSizeHuge); - else if (numberPlayableCells >= 90 * 90) size += " " + TranslationProvider.GetString(MapSizeLarge); - else if (numberPlayableCells >= 60 * 60) size += " " + TranslationProvider.GetString(MapSizeMedium); - else size += " " + TranslationProvider.GetString(MapSizeSmall); + if (numberPlayableCells >= 120 * 120) size += " " + FluentProvider.GetString(MapSizeHuge); + else if (numberPlayableCells >= 90 * 90) size += " " + FluentProvider.GetString(MapSizeLarge); + else if (numberPlayableCells >= 60 * 60) size += " " + FluentProvider.GetString(MapSizeMedium); + else size += " " + FluentProvider.GetString(MapSizeSmall); sizeWidget.GetText = () => size; } @@ -502,7 +502,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } catch (Exception ex) { - TextNotificationsManager.Debug(TranslationProvider.GetString(MapDeletionFailed, Translation.Arguments("map", map))); + TextNotificationsManager.Debug(FluentProvider.GetString(MapDeletionFailed, FluentBundle.Arguments("map", map))); Log.Write("debug", ex.ToString()); } @@ -514,7 +514,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: DeleteMapTitle, text: DeleteMapPrompt, - textArguments: Translation.Arguments("title", modData.MapCache[map].Title), + textArguments: FluentBundle.Arguments("title", modData.MapCache[map].Title), onConfirm: () => { var newUid = DeleteMap(map); diff --git a/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs index ffb56e796a..69edb0761f 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs @@ -27,25 +27,25 @@ namespace OpenRA.Mods.Common.Widgets.Logic enum PlayingVideo { None, Info, Briefing, GameStart } enum PanelType { MissionInfo, Options } - [TranslationReference] + [FluentReference] const string NoVideoTitle = "dialog-no-video.title"; - [TranslationReference] + [FluentReference] const string NoVideoPrompt = "dialog-no-video.prompt"; - [TranslationReference] + [FluentReference] const string NoVideoCancel = "dialog-no-video.cancel"; - [TranslationReference] + [FluentReference] const string CantPlayTitle = "dialog-cant-play-video.title"; - [TranslationReference] + [FluentReference] const string CantPlayPrompt = "dialog-cant-play-video.prompt"; - [TranslationReference] + [FluentReference] const string CantPlayCancel = "dialog-cant-play-video.cancel"; - [TranslationReference] + [FluentReference] const string NotAvailable = "label-not-available"; readonly ModData modData; @@ -386,7 +386,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (option.Values.TryGetValue(missionOptions[option.Id], out var value)) return value; - return TranslationProvider.GetString(NotAvailable); + return FluentProvider.GetString(NotAvailable); }; if (option.Description != null) diff --git a/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs index facd52fca1..18393a655b 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs @@ -18,10 +18,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class MusicPlayerLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string SoundMuted = "label-sound-muted"; - [TranslationReference] + [FluentReference] const string NoSongPlaying = "label-no-song-playing"; readonly ScrollPanelWidget musicList; @@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic panel.Get("MUTE_LABEL").GetText = () => { if (Game.Settings.Sound.Mute) - return TranslationProvider.GetString(SoundMuted); + return FluentProvider.GetString(SoundMuted); return ""; }; @@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic return $"{minutes:D2}:{seconds:D2} / {totalMinutes:D2}:{totalSeconds:D2}"; }; - var noSongPlaying = TranslationProvider.GetString(NoSongPlaying); + var noSongPlaying = FluentProvider.GetString(NoSongPlaying); var musicTitle = panel.GetOrNull("TITLE_LABEL"); if (musicTitle != null) musicTitle.GetText = () => currentSong != null ? currentSong.Title : noSongPlaying; diff --git a/OpenRA.Mods.Common/Widgets/Logic/MuteHotkeyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MuteHotkeyLogic.cs index 6a9a1e6277..dfaddd1b16 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MuteHotkeyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MuteHotkeyLogic.cs @@ -18,10 +18,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic [ChromeLogicArgsHotkeys("MuteAudioKey")] public class MuteHotkeyLogic : SingleHotkeyBaseLogic { - [TranslationReference] + [FluentReference] const string AudioMuted = "label-audio-muted"; - [TranslationReference] + [FluentReference] const string AudioUnmuted = "label-audio-unmuted"; [ObjectCreator.UseCtor] @@ -35,12 +35,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (Game.Settings.Sound.Mute) { Game.Sound.MuteAudio(); - TextNotificationsManager.AddFeedbackLine(TranslationProvider.GetString(AudioMuted)); + TextNotificationsManager.AddFeedbackLine(FluentProvider.GetString(AudioMuted)); } else { Game.Sound.UnmuteAudio(); - TextNotificationsManager.AddFeedbackLine(TranslationProvider.GetString(AudioUnmuted)); + TextNotificationsManager.AddFeedbackLine(FluentProvider.GetString(AudioUnmuted)); } return true; diff --git a/OpenRA.Mods.Common/Widgets/Logic/PlayerProfileLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/PlayerProfileLogic.cs index e1486fc20b..1b6636b014 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/PlayerProfileLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/PlayerProfileLogic.cs @@ -128,10 +128,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic public class RegisteredProfileTooltipLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string LoadingPlayerProfile = "label-loading-player-profile"; - [TranslationReference] + [FluentReference] const string LoadingPlayerProfileFailed = "label-loading-player-profile-failed"; readonly PlayerDatabase playerDatabase; @@ -157,7 +157,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var profileWidth = 0; var maxProfileWidth = widget.Bounds.Width; - var messageText = TranslationProvider.GetString(LoadingPlayerProfile); + var messageText = FluentProvider.GetString(LoadingPlayerProfile); var messageWidth = messageFont.Measure(messageText).X + 2 * message.Bounds.Left; Task.Run(async () => @@ -247,7 +247,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { if (profile == null) { - messageText = TranslationProvider.GetString(LoadingPlayerProfileFailed); + messageText = FluentProvider.GetString(LoadingPlayerProfileFailed); messageWidth = messageFont.Measure(messageText).X + 2 * message.Bounds.Left; header.Bounds.Width = widget.Bounds.Width = messageWidth; } @@ -355,7 +355,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic public class BotTooltipLogic : ChromeLogic { - [TranslationReference("name")] + [FluentReference("name")] const string BotManagedBy = "label-bot-managed-by-tooltip"; [ObjectCreator.UseCtor] @@ -365,7 +365,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var nameFont = Game.Renderer.Fonts[nameLabel.Font]; var controller = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.Index == client.BotControllerClientIndex); if (controller != null) - nameLabel.GetText = () => TranslationProvider.GetString(BotManagedBy, Translation.Arguments("name", controller.Name)); + nameLabel.GetText = () => FluentProvider.GetString(BotManagedBy, FluentBundle.Arguments("name", controller.Name)); widget.Bounds.Width = nameFont.Measure(nameLabel.GetText()).X + 2 * nameLabel.Bounds.Left; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs index 66344c3500..730d44cbd4 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs @@ -26,82 +26,82 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class ReplayBrowserLogic : ChromeLogic { - [TranslationReference("time")] + [FluentReference("time")] const string Duration = "label-duration"; - [TranslationReference] + [FluentReference] const string Singleplayer = "options-replay-type.singleplayer"; - [TranslationReference] + [FluentReference] const string Multiplayer = "options-replay-type.multiplayer"; - [TranslationReference] + [FluentReference] const string Today = "options-replay-date.today"; - [TranslationReference] + [FluentReference] const string LastWeek = "options-replay-date.last-week"; - [TranslationReference] + [FluentReference] const string LastFortnight = "options-replay-date.last-fortnight"; - [TranslationReference] + [FluentReference] const string LastMonth = "options-replay-date.last-month"; - [TranslationReference] + [FluentReference] const string ReplayDurationVeryShort = "options-replay-duration.very-short"; - [TranslationReference] + [FluentReference] const string ReplayDurationShort = "options-replay-duration.short"; - [TranslationReference] + [FluentReference] const string ReplayDurationMedium = "options-replay-duration.medium"; - [TranslationReference] + [FluentReference] const string ReplayDurationLong = "options-replay-duration.long"; - [TranslationReference] + [FluentReference] const string RenameReplayTitle = "dialog-rename-replay.title"; - [TranslationReference] + [FluentReference] const string RenameReplayPrompt = "dialog-rename-replay.prompt"; - [TranslationReference] + [FluentReference] const string RenameReplayAccept = "dialog-rename-replay.confirm"; - [TranslationReference] + [FluentReference] const string DeleteReplayTitle = "dialog-delete-replay.title"; - [TranslationReference("replay")] + [FluentReference("replay")] const string DeleteReplayPrompt = "dialog-delete-replay.prompt"; - [TranslationReference] + [FluentReference] const string DeleteReplayAccept = "dialog-delete-replay.confirm"; - [TranslationReference] + [FluentReference] const string DeleteAllReplaysTitle = "dialog-delete-all-replays.title"; - [TranslationReference("count")] + [FluentReference("count")] const string DeleteAllReplaysPrompt = "dialog-delete-all-replays.prompt"; - [TranslationReference] + [FluentReference] const string DeleteAllReplaysAccept = "dialog-delete-all-replays.confirm"; - [TranslationReference("file")] + [FluentReference("file")] const string ReplayDeletionFailed = "notification-replay-deletion-failed"; - [TranslationReference] + [FluentReference] const string Players = "label-players"; - [TranslationReference("team")] + [FluentReference("team")] const string TeamNumber = "label-team-name"; - [TranslationReference] + [FluentReference] const string NoTeam = "label-no-team"; - [TranslationReference] + [FluentReference] const string Victory = "options-winstate.victory"; - [TranslationReference] + [FluentReference] const string Defeat = "options-winstate.defeat"; static Filter filter = new(); @@ -182,7 +182,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic }); var replayDuration = new CachedTransform(r => - TranslationProvider.GetString(Duration, Translation.Arguments("time", WidgetUtils.FormatTimeSeconds((int)selectedReplay.GameInfo.Duration.TotalSeconds)))); + FluentProvider.GetString(Duration, FluentBundle.Arguments("time", WidgetUtils.FormatTimeSeconds((int)selectedReplay.GameInfo.Duration.TotalSeconds)))); panel.Get("DURATION").GetText = () => replayDuration.Update(selectedReplay); SetupFilters(); @@ -234,8 +234,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic var options = new List<(GameType GameType, string Text)> { (GameType.Any, ddb.GetText()), - (GameType.Singleplayer, TranslationProvider.GetString(Singleplayer)), - (GameType.Multiplayer, TranslationProvider.GetString(Multiplayer)) + (GameType.Singleplayer, FluentProvider.GetString(Singleplayer)), + (GameType.Multiplayer, FluentProvider.GetString(Multiplayer)) }; var lookup = options.ToDictionary(kvp => kvp.GameType, kvp => kvp.Text); @@ -267,10 +267,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic var options = new List<(DateType DateType, string Text)> { (DateType.Any, ddb.GetText()), - (DateType.Today, TranslationProvider.GetString(Today)), - (DateType.LastWeek, TranslationProvider.GetString(LastWeek)), - (DateType.LastFortnight, TranslationProvider.GetString(LastFortnight)), - (DateType.LastMonth, TranslationProvider.GetString(LastMonth)) + (DateType.Today, FluentProvider.GetString(Today)), + (DateType.LastWeek, FluentProvider.GetString(LastWeek)), + (DateType.LastFortnight, FluentProvider.GetString(LastFortnight)), + (DateType.LastMonth, FluentProvider.GetString(LastMonth)) }; var lookup = options.ToDictionary(kvp => kvp.DateType, kvp => kvp.Text); @@ -303,10 +303,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic var options = new List<(DurationType DurationType, string Text)> { (DurationType.Any, ddb.GetText()), - (DurationType.VeryShort, TranslationProvider.GetString(ReplayDurationVeryShort)), - (DurationType.Short, TranslationProvider.GetString(ReplayDurationShort)), - (DurationType.Medium, TranslationProvider.GetString(ReplayDurationMedium)), - (DurationType.Long, TranslationProvider.GetString(ReplayDurationLong)) + (DurationType.VeryShort, FluentProvider.GetString(ReplayDurationVeryShort)), + (DurationType.Short, FluentProvider.GetString(ReplayDurationShort)), + (DurationType.Medium, FluentProvider.GetString(ReplayDurationMedium)), + (DurationType.Long, FluentProvider.GetString(ReplayDurationLong)) }; var lookup = options.ToDictionary(kvp => kvp.DurationType, kvp => kvp.Text); @@ -340,8 +340,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic var options = new List<(WinState WinState, string Text)> { (WinState.Undefined, ddb.GetText()), - (WinState.Lost, TranslationProvider.GetString(Defeat)), - (WinState.Won, TranslationProvider.GetString(Victory)) + (WinState.Lost, FluentProvider.GetString(Defeat)), + (WinState.Won, FluentProvider.GetString(Victory)) }; var lookup = options.ToDictionary(kvp => kvp.WinState, kvp => kvp.Text); @@ -446,7 +446,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic options.Insert(0, null); // no filter var anyText = ddb.GetText(); - ddb.GetText = () => string.IsNullOrEmpty(filter.Faction) ? anyText : TranslationProvider.GetString(filter.Faction); + ddb.GetText = () => string.IsNullOrEmpty(filter.Faction) ? anyText : FluentProvider.GetString(filter.Faction); ddb.OnMouseDown = _ => { ScrollItemWidget SetupItem(string option, ScrollItemWidget tpl) @@ -455,7 +455,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic tpl, () => string.Equals(filter.Faction, option, StringComparison.CurrentCultureIgnoreCase), () => { filter.Faction = option; ApplyFilter(); }); - item.Get("LABEL").GetText = () => option != null ? TranslationProvider.GetString(option) : anyText; + item.Get("LABEL").GetText = () => option != null ? FluentProvider.GetString(option) : anyText; return item; } @@ -507,7 +507,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: DeleteReplayTitle, text: DeleteReplayPrompt, - textArguments: Translation.Arguments("replay", Path.GetFileNameWithoutExtension(r.FilePath)), + textArguments: FluentBundle.Arguments("replay", Path.GetFileNameWithoutExtension(r.FilePath)), onConfirm: () => { DeleteReplay(r); @@ -545,7 +545,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: DeleteAllReplaysTitle, text: DeleteAllReplaysPrompt, - textArguments: Translation.Arguments("count", list.Count), + textArguments: FluentBundle.Arguments("count", list.Count), onConfirm: () => { foreach (var replayMetadata in list) @@ -584,7 +584,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } catch (Exception ex) { - TextNotificationsManager.Debug(TranslationProvider.GetString(ReplayDeletionFailed, Translation.Arguments("file", replay.FilePath))); + TextNotificationsManager.Debug(FluentProvider.GetString(ReplayDeletionFailed, FluentBundle.Arguments("file", replay.FilePath))); Log.Write("debug", ex.ToString()); return; } @@ -724,9 +724,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic var noTeams = players.Count == 1; foreach (var p in players) { - var label = noTeams ? TranslationProvider.GetString(Players) : p.Key > 0 - ? TranslationProvider.GetString(TeamNumber, Translation.Arguments("team", p.Key)) - : TranslationProvider.GetString(NoTeam); + var label = noTeams ? FluentProvider.GetString(Players) : p.Key > 0 + ? FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", p.Key)) + : FluentProvider.GetString(NoTeam); teams.Add(label, p); } diff --git a/OpenRA.Mods.Common/Widgets/Logic/ReplayUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/ReplayUtils.cs index 6039161609..ae1e879360 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ReplayUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ReplayUtils.cs @@ -17,28 +17,28 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public static class ReplayUtils { - [TranslationReference] + [FluentReference] const string IncompatibleReplayTitle = "dialog-incompatible-replay.title"; - [TranslationReference] + [FluentReference] const string IncompatibleReplayPrompt = "dialog-incompatible-replay.prompt"; - [TranslationReference] + [FluentReference] const string IncompatibleReplayAccept = "dialog-incompatible-replay.confirm"; - [TranslationReference] + [FluentReference] const string UnknownVersion = "dialog-incompatible-replay.prompt-unknown-version"; - [TranslationReference] + [FluentReference] const string UnknownMod = "dialog-incompatible-replay.prompt-unknown-mod"; - [TranslationReference("mod")] + [FluentReference("mod")] const string UnvailableMod = "dialog-incompatible-replay.prompt-unavailable-mod"; - [TranslationReference("version")] + [FluentReference("version")] const string IncompatibleVersion = "dialog-incompatible-replay.prompt-incompatible-version"; - [TranslationReference("map")] + [FluentReference("map")] const string UnvailableMap = "dialog-incompatible-replay.prompt-unavailable-map"; static readonly Action DoNothing = () => { }; @@ -59,13 +59,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic return IncompatibleReplayDialog(UnknownMod, null, modData, onCancel); if (!Game.Mods.ContainsKey(mod)) - return IncompatibleReplayDialog(UnvailableMod, Translation.Arguments("mod", mod), modData, onCancel); + return IncompatibleReplayDialog(UnvailableMod, FluentBundle.Arguments("mod", mod), modData, onCancel); if (Game.Mods[mod].Metadata.Version != version) - return IncompatibleReplayDialog(IncompatibleVersion, Translation.Arguments("version", version), modData, onCancel); + return IncompatibleReplayDialog(IncompatibleVersion, FluentBundle.Arguments("version", version), modData, onCancel); if (replayMeta.GameInfo.MapPreview.Status != MapStatus.Available) - return IncompatibleReplayDialog(UnvailableMap, Translation.Arguments("map", replayMeta.GameInfo.MapUid), modData, onCancel); + return IncompatibleReplayDialog(UnvailableMap, FluentBundle.Arguments("map", replayMeta.GameInfo.MapUid), modData, onCancel); return true; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs index 350712991d..23573de3ad 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ServerCreationLogic.cs @@ -19,37 +19,37 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class ServerCreationLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string InternetServerNatA = "label-internet-server-nat-A"; - [TranslationReference] + [FluentReference] const string InternetServerNatBenabled = "label-internet-server-nat-B-enabled"; - [TranslationReference] + [FluentReference] const string InternetServerNatBnotSupported = "label-internet-server-nat-B-not-supported"; - [TranslationReference] + [FluentReference] const string InternetServerNatBdisabled = "label-internet-server-nat-B-disabled"; - [TranslationReference] + [FluentReference] const string InternetServerNatC = "label-internet-server-nat-C"; - [TranslationReference] + [FluentReference] const string LocalServer = "label-local-server"; - [TranslationReference("port")] + [FluentReference("port")] const string ServerCreationFailedPrompt = "dialog-server-creation-failed.prompt"; - [TranslationReference] + [FluentReference] const string ServerCreationFailedPortUsed = "dialog-server-creation-failed.prompt-port-used"; - [TranslationReference("message", "code")] + [FluentReference("message", "code")] const string ServerCreationFailedError = "dialog-server-creation-failed.prompt-error"; - [TranslationReference] + [FluentReference] const string ServerCreationFailedTitle = "dialog-server-creation-failed.title"; - [TranslationReference] + [FluentReference] const string ServerCreationFailedCancel = "dialog-server-creation-failed.cancel"; readonly Widget panel; @@ -170,15 +170,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (advertiseOnline) { - var noticesLabelAText = TranslationProvider.GetString(InternetServerNatA) + " "; + var noticesLabelAText = FluentProvider.GetString(InternetServerNatA) + " "; noticesLabelA.GetText = () => noticesLabelAText; var aWidth = Game.Renderer.Fonts[noticesLabelA.Font].Measure(noticesLabelAText).X; noticesLabelA.Bounds.Width = aWidth; var noticesLabelBText = - Nat.Status == NatStatus.Enabled ? TranslationProvider.GetString(InternetServerNatBenabled) : - Nat.Status == NatStatus.NotSupported ? TranslationProvider.GetString(InternetServerNatBnotSupported) : - TranslationProvider.GetString(InternetServerNatBdisabled); + Nat.Status == NatStatus.Enabled ? FluentProvider.GetString(InternetServerNatBenabled) : + Nat.Status == NatStatus.NotSupported ? FluentProvider.GetString(InternetServerNatBnotSupported) : + FluentProvider.GetString(InternetServerNatBdisabled); noticesLabelB.GetText = () => noticesLabelBText; noticesLabelB.TextColor = @@ -191,14 +191,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic noticesLabelB.Bounds.Width = bWidth; noticesLabelB.Visible = true; - var noticesLabelCText = TranslationProvider.GetString(InternetServerNatC); + var noticesLabelCText = FluentProvider.GetString(InternetServerNatC); noticesLabelC.GetText = () => noticesLabelCText; noticesLabelC.Bounds.X = noticesLabelB.Bounds.Right; noticesLabelC.Visible = true; } else { - var noticesLabelAText = TranslationProvider.GetString(LocalServer); + var noticesLabelAText = FluentProvider.GetString(LocalServer); noticesLabelA.GetText = () => noticesLabelAText; noticesLabelB.Visible = false; noticesLabelC.Visible = false; @@ -239,14 +239,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic } catch (System.Net.Sockets.SocketException e) { - var message = TranslationProvider.GetString(ServerCreationFailedPrompt, Translation.Arguments("port", Game.Settings.Server.ListenPort)); + var message = FluentProvider.GetString(ServerCreationFailedPrompt, FluentBundle.Arguments("port", Game.Settings.Server.ListenPort)); // AddressAlreadyInUse (WSAEADDRINUSE) if (e.ErrorCode == 10048) - message += "\n" + TranslationProvider.GetString(ServerCreationFailedPortUsed); + message += "\n" + FluentProvider.GetString(ServerCreationFailedPortUsed); else - message += "\n" + TranslationProvider.GetString(ServerCreationFailedError, - Translation.Arguments("message", e.Message, "code", e.ErrorCode)); + message += "\n" + FluentProvider.GetString(ServerCreationFailedError, + FluentBundle.Arguments("message", e.Message, "code", e.ErrorCode)); ConfirmationDialogs.ButtonPrompt(modData, ServerCreationFailedTitle, message, onCancel: () => { }, cancelText: ServerCreationFailedCancel); diff --git a/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs index 12a4e4efb4..c853e9c748 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs @@ -25,67 +25,67 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class ServerListLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string SearchStatusFailed = "label-search-status-failed"; - [TranslationReference] + [FluentReference] const string SearchStatusNoGames = "label-search-status-no-games"; - [TranslationReference("players")] + [FluentReference("players")] const string PlayersOnline = "label-players-online-count"; - [TranslationReference] + [FluentReference] const string NoServerSelected = "label-no-server-selected"; - [TranslationReference] + [FluentReference] const string MapStatusSearching = "label-map-status-searching"; - [TranslationReference] + [FluentReference] const string MapClassificationUnknown = "label-map-classification-unknown"; - [TranslationReference("players")] + [FluentReference("players")] const string PlayersLabel = "label-players-count"; - [TranslationReference("bots")] + [FluentReference("bots")] const string BotsLabel = "label-bots-count"; - [TranslationReference("spectators")] + [FluentReference("spectators")] const string SpectatorsLabel = "label-spectators-count"; - [TranslationReference] + [FluentReference] const string Players = "label-players"; - [TranslationReference("team")] + [FluentReference("team")] const string TeamNumber = "label-team-name"; - [TranslationReference] + [FluentReference] const string NoTeam = "label-no-team"; - [TranslationReference] + [FluentReference] const string Spectators = "label-spectators"; - [TranslationReference("players")] + [FluentReference("players")] const string OtherPlayers = "label-other-players-count"; - [TranslationReference] + [FluentReference] const string Playing = "label-playing"; - [TranslationReference] + [FluentReference] const string Waiting = "label-waiting"; - [TranslationReference("minutes")] + [FluentReference("minutes")] const string InProgress = "label-in-progress-for"; - [TranslationReference] + [FluentReference] const string PasswordProtected = "label-password-protected"; - [TranslationReference] + [FluentReference] const string WaitingForPlayers = "label-waiting-for-players"; - [TranslationReference] + [FluentReference] const string ServerShuttingDown = "label-server-shutting-down"; - [TranslationReference] + [FluentReference] const string UnknownServerState = "label-unknown-server-state"; readonly string noServerSelected; @@ -145,8 +145,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic { switch (searchStatus) { - case SearchStatus.Failed: return TranslationProvider.GetString(SearchStatusFailed); - case SearchStatus.NoGames: return TranslationProvider.GetString(SearchStatusNoGames); + case SearchStatus.Failed: return FluentProvider.GetString(SearchStatusFailed); + case SearchStatus.NoGames: return FluentProvider.GetString(SearchStatusNoGames); default: return ""; } } @@ -157,22 +157,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic this.modData = modData; this.onJoin = onJoin; - playing = TranslationProvider.GetString(Playing); - waiting = TranslationProvider.GetString(Waiting); + playing = FluentProvider.GetString(Playing); + waiting = FluentProvider.GetString(Waiting); - noServerSelected = TranslationProvider.GetString(NoServerSelected); - mapStatusSearching = TranslationProvider.GetString(MapStatusSearching); - mapClassificationUnknown = TranslationProvider.GetString(MapClassificationUnknown); + noServerSelected = FluentProvider.GetString(NoServerSelected); + mapStatusSearching = FluentProvider.GetString(MapStatusSearching); + mapClassificationUnknown = FluentProvider.GetString(MapClassificationUnknown); - players = new CachedTransform(i => TranslationProvider.GetString(PlayersLabel, Translation.Arguments("players", i))); - bots = new CachedTransform(i => TranslationProvider.GetString(BotsLabel, Translation.Arguments("bots", i))); - spectators = new CachedTransform(i => TranslationProvider.GetString(SpectatorsLabel, Translation.Arguments("spectators", i))); + players = new CachedTransform(i => FluentProvider.GetString(PlayersLabel, FluentBundle.Arguments("players", i))); + bots = new CachedTransform(i => FluentProvider.GetString(BotsLabel, FluentBundle.Arguments("bots", i))); + spectators = new CachedTransform(i => FluentProvider.GetString(SpectatorsLabel, FluentBundle.Arguments("spectators", i))); - minutes = new CachedTransform(i => TranslationProvider.GetString(InProgress, Translation.Arguments("minutes", i))); - passwordProtected = TranslationProvider.GetString(PasswordProtected); - waitingForPlayers = TranslationProvider.GetString(WaitingForPlayers); - serverShuttingDown = TranslationProvider.GetString(ServerShuttingDown); - unknownServerState = TranslationProvider.GetString(UnknownServerState); + minutes = new CachedTransform(i => FluentProvider.GetString(InProgress, FluentBundle.Arguments("minutes", i))); + passwordProtected = FluentProvider.GetString(PasswordProtected); + waitingForPlayers = FluentProvider.GetString(WaitingForPlayers); + serverShuttingDown = FluentProvider.GetString(ServerShuttingDown); + unknownServerState = FluentProvider.GetString(UnknownServerState); services = modData.Manifest.Get(); @@ -318,7 +318,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var playersLabel = widget.GetOrNull("PLAYER_COUNT"); if (playersLabel != null) { - var playersText = new CachedTransform(p => TranslationProvider.GetString(PlayersOnline, Translation.Arguments("players", p))); + var playersText = new CachedTransform(p => FluentProvider.GetString(PlayersOnline, FluentBundle.Arguments("players", p))); playersLabel.IsVisible = () => playerCount != 0; playersLabel.GetText = () => playersText.Update(playerCount); } @@ -581,14 +581,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic var noTeams = players.Count == 1; foreach (var p in players) { - var label = noTeams ? TranslationProvider.GetString(Players) : p.Key > 0 - ? TranslationProvider.GetString(TeamNumber, Translation.Arguments("team", p.Key)) - : TranslationProvider.GetString(NoTeam); + var label = noTeams ? FluentProvider.GetString(Players) : p.Key > 0 + ? FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", p.Key)) + : FluentProvider.GetString(NoTeam); teams.Add(label, p); } if (server.Clients.Any(c => c.IsSpectator)) - teams.Add(TranslationProvider.GetString(Spectators), server.Clients.Where(c => c.IsSpectator)); + teams.Add(FluentProvider.GetString(Spectators), server.Clients.Where(c => c.IsSpectator)); var factionInfo = modData.DefaultRules.Actors[SystemActors.World].TraitInfos(); foreach (var kv in teams) @@ -765,7 +765,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (game.Clients.Length > 10) displayClients = displayClients .Take(9) - .Append(TranslationProvider.GetString(OtherPlayers, Translation.Arguments("players", game.Clients.Length - 9))); + .Append(FluentProvider.GetString(OtherPlayers, FluentBundle.Arguments("players", game.Clients.Length - 9))); var tooltip = displayClients.JoinWith("\n"); players.GetTooltipText = () => tooltip; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs index ff614c8c64..2b637ba7a2 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs @@ -23,49 +23,49 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class DisplaySettingsLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string Close = "options-camera.close"; - [TranslationReference] + [FluentReference] const string Medium = "options-camera.medium"; - [TranslationReference] + [FluentReference] const string Far = "options-camera.far"; - [TranslationReference] + [FluentReference] const string Furthest = "options-camera.furthest"; - [TranslationReference] + [FluentReference] const string Windowed = "options-display-mode.windowed"; - [TranslationReference] + [FluentReference] const string LegacyFullscreen = "options-display-mode.legacy-fullscreen"; - [TranslationReference] + [FluentReference] const string Fullscreen = "options-display-mode.fullscreen"; - [TranslationReference("number")] + [FluentReference("number")] const string Display = "label-video-display-index"; - [TranslationReference] + [FluentReference] const string Standard = "options-status-bars.standard"; - [TranslationReference] + [FluentReference] const string ShowOnDamage = "options-status-bars.show-on-damage"; - [TranslationReference] + [FluentReference] const string AlwaysShow = "options-status-bars.always-show"; - [TranslationReference] + [FluentReference] const string Automatic = "options-target-lines.automatic"; - [TranslationReference] + [FluentReference] const string Manual = "options-target-lines.manual"; - [TranslationReference] + [FluentReference] const string Disabled = "options-target-lines.disabled"; - [TranslationReference("fps")] + [FluentReference("fps")] const string FrameLimiter = "checkbox-frame-limiter"; static readonly int OriginalVideoDisplay; static readonly WindowMode OriginalGraphicsMode; @@ -106,17 +106,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic this.modData = modData; viewportSizes = modData.Manifest.Get(); - legacyFullscreen = TranslationProvider.GetString(LegacyFullscreen); - fullscreen = TranslationProvider.GetString(Fullscreen); + legacyFullscreen = FluentProvider.GetString(LegacyFullscreen); + fullscreen = FluentProvider.GetString(Fullscreen); registerPanel(panelID, label, InitPanel, ResetPanel); - showOnDamage = TranslationProvider.GetString(ShowOnDamage); - alwaysShow = TranslationProvider.GetString(AlwaysShow); + showOnDamage = FluentProvider.GetString(ShowOnDamage); + alwaysShow = FluentProvider.GetString(AlwaysShow); - automatic = TranslationProvider.GetString(Automatic); - manual = TranslationProvider.GetString(Manual); - disabled = TranslationProvider.GetString(Disabled); + automatic = FluentProvider.GetString(Automatic); + manual = FluentProvider.GetString(Manual); + disabled = FluentProvider.GetString(Disabled); } public static string GetViewportSizeName(ModData modData, WorldViewport worldViewport) @@ -124,13 +124,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic switch (worldViewport) { case WorldViewport.Close: - return TranslationProvider.GetString(Close); + return FluentProvider.GetString(Close); case WorldViewport.Medium: - return TranslationProvider.GetString(Medium); + return FluentProvider.GetString(Medium); case WorldViewport.Far: - return TranslationProvider.GetString(Far); + return FluentProvider.GetString(Far); case WorldViewport.Native: - return TranslationProvider.GetString(Furthest); + return FluentProvider.GetString(Furthest); default: return ""; } @@ -166,12 +166,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic var windowModeDropdown = panel.Get("MODE_DROPDOWN"); windowModeDropdown.OnMouseDown = _ => ShowWindowModeDropdown(windowModeDropdown, ds, scrollPanel); windowModeDropdown.GetText = () => ds.Mode == WindowMode.Windowed - ? TranslationProvider.GetString(Windowed) + ? FluentProvider.GetString(Windowed) : ds.Mode == WindowMode.Fullscreen ? legacyFullscreen : fullscreen; var displaySelectionDropDown = panel.Get("DISPLAY_SELECTION_DROPDOWN"); displaySelectionDropDown.OnMouseDown = _ => ShowDisplaySelectionDropdown(displaySelectionDropDown, ds); - var displaySelectionLabel = new CachedTransform(i => TranslationProvider.GetString(Display, Translation.Arguments("number", i + 1))); + var displaySelectionLabel = new CachedTransform(i => FluentProvider.GetString(Display, FluentBundle.Arguments("number", i + 1))); displaySelectionDropDown.GetText = () => displaySelectionLabel.Update(ds.VideoDisplay); displaySelectionDropDown.IsDisabled = () => Game.Renderer.DisplayCount < 2; @@ -185,7 +185,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var statusBarsDropDown = panel.Get("STATUS_BAR_DROPDOWN"); statusBarsDropDown.OnMouseDown = _ => ShowStatusBarsDropdown(statusBarsDropDown, gs); statusBarsDropDown.GetText = () => gs.StatusBars == StatusBarsType.Standard - ? TranslationProvider.GetString(Standard) + ? FluentProvider.GetString(Standard) : gs.StatusBars == StatusBarsType.DamageShow ? showOnDamage : alwaysShow; @@ -242,7 +242,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var frameLimitGamespeedCheckbox = panel.Get("FRAME_LIMIT_GAMESPEED_CHECKBOX"); var frameLimitCheckbox = panel.Get("FRAME_LIMIT_CHECKBOX"); - var frameLimitLabel = new CachedTransform(fps => TranslationProvider.GetString(FrameLimiter, Translation.Arguments("fps", fps))); + var frameLimitLabel = new CachedTransform(fps => FluentProvider.GetString(FrameLimiter, FluentBundle.Arguments("fps", fps))); frameLimitCheckbox.GetText = () => frameLimitLabel.Update(ds.MaxFramerate); frameLimitCheckbox.IsDisabled = () => ds.CapFramerateToGameFps; @@ -350,9 +350,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var options = new Dictionary() { - { TranslationProvider.GetString(Fullscreen), WindowMode.PseudoFullscreen }, - { TranslationProvider.GetString(LegacyFullscreen), WindowMode.Fullscreen }, - { TranslationProvider.GetString(Windowed), WindowMode.Windowed }, + { FluentProvider.GetString(Fullscreen), WindowMode.PseudoFullscreen }, + { FluentProvider.GetString(LegacyFullscreen), WindowMode.Fullscreen }, + { FluentProvider.GetString(Windowed), WindowMode.Windowed }, }; ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate) @@ -399,9 +399,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var options = new Dictionary() { - { TranslationProvider.GetString(Standard), StatusBarsType.Standard }, - { TranslationProvider.GetString(ShowOnDamage), StatusBarsType.DamageShow }, - { TranslationProvider.GetString(AlwaysShow), StatusBarsType.AlwaysShow }, + { FluentProvider.GetString(Standard), StatusBarsType.Standard }, + { FluentProvider.GetString(ShowOnDamage), StatusBarsType.DamageShow }, + { FluentProvider.GetString(AlwaysShow), StatusBarsType.AlwaysShow }, }; ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate) @@ -454,9 +454,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var options = new Dictionary() { - { TranslationProvider.GetString(Automatic), TargetLinesType.Automatic }, - { TranslationProvider.GetString(Manual), TargetLinesType.Manual }, - { TranslationProvider.GetString(Disabled), TargetLinesType.Disabled }, + { FluentProvider.GetString(Automatic), TargetLinesType.Automatic }, + { FluentProvider.GetString(Manual), TargetLinesType.Manual }, + { FluentProvider.GetString(Disabled), TargetLinesType.Disabled }, }; ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs index 1485a9c837..61268c9ac9 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs @@ -19,10 +19,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class HotkeysSettingsLogic : ChromeLogic { - [TranslationReference("key")] + [FluentReference("key")] const string OriginalNotice = "label-original-notice"; - [TranslationReference("key", "context")] + [FluentReference("key", "context")] const string DuplicateNotice = "label-duplicate-notice"; readonly ModData modData; @@ -229,7 +229,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic duplicateNotice.IsVisible = () => !isHotkeyValid; var duplicateNoticeText = new CachedTransform(hd => hd != null ? - TranslationProvider.GetString(DuplicateNotice, Translation.Arguments("key", hd.Description, + FluentProvider.GetString(DuplicateNotice, FluentBundle.Arguments("key", hd.Description, "context", hd.Contexts.First(c => selectedHotkeyDefinition.Contexts.Contains(c)))) : ""); duplicateNotice.GetText = () => duplicateNoticeText.Update(duplicateHotkeyDefinition); @@ -238,7 +238,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic originalNotice.TextColor = ChromeMetrics.Get("NoticeInfoColor"); originalNotice.IsVisible = () => isHotkeyValid && !isHotkeyDefault; var originalNoticeText = new CachedTransform(hd => - TranslationProvider.GetString(OriginalNotice, Translation.Arguments("key", hd?.Default.DisplayString()))); + FluentProvider.GetString(OriginalNotice, FluentBundle.Arguments("key", hd?.Default.DisplayString()))); originalNotice.GetText = () => originalNoticeText.Update(selectedHotkeyDefinition); var readonlyNotice = panel.Get("READONLY_NOTICE"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/InputSettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/InputSettingsLogic.cs index b447311f40..54cb3c8e1f 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/InputSettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/InputSettingsLogic.cs @@ -18,37 +18,37 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class InputSettingsLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string Classic = "options-control-scheme.classic"; - [TranslationReference] + [FluentReference] const string Modern = "options-control-scheme.modern"; - [TranslationReference] + [FluentReference] const string Disabled = "options-mouse-scroll-type.disabled"; - [TranslationReference] + [FluentReference] const string Standard = "options-mouse-scroll-type.standard"; - [TranslationReference] + [FluentReference] const string Inverted = "options-mouse-scroll-type.inverted"; - [TranslationReference] + [FluentReference] const string Joystick = "options-mouse-scroll-type.joystick"; - [TranslationReference] + [FluentReference] const string Alt = "options-zoom-modifier.alt"; - [TranslationReference] + [FluentReference] const string Ctrl = "options-zoom-modifier.ctrl"; - [TranslationReference] + [FluentReference] const string Meta = "options-zoom-modifier.meta"; - [TranslationReference] + [FluentReference] const string Shift = "options-zoom-modifier.shift"; - [TranslationReference] + [FluentReference] const string None = "options-zoom-modifier.none"; static InputSettingsLogic() { } @@ -59,8 +59,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic [ObjectCreator.UseCtor] public InputSettingsLogic(Action>, Func> registerPanel, string panelID, string label) { - classic = TranslationProvider.GetString(Classic); - modern = TranslationProvider.GetString(Modern); + classic = FluentProvider.GetString(Classic); + modern = FluentProvider.GetString(Modern); registerPanel(panelID, label, InitPanel, ResetPanel); } @@ -163,8 +163,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var options = new Dictionary() { - { TranslationProvider.GetString(Classic), true }, - { TranslationProvider.GetString(Modern), false }, + { FluentProvider.GetString(Classic), true }, + { FluentProvider.GetString(Modern), false }, }; ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate) @@ -183,10 +183,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var options = new Dictionary() { - { TranslationProvider.GetString(Disabled), MouseScrollType.Disabled }, - { TranslationProvider.GetString(Standard), MouseScrollType.Standard }, - { TranslationProvider.GetString(Inverted), MouseScrollType.Inverted }, - { TranslationProvider.GetString(Joystick), MouseScrollType.Joystick }, + { FluentProvider.GetString(Disabled), MouseScrollType.Disabled }, + { FluentProvider.GetString(Standard), MouseScrollType.Standard }, + { FluentProvider.GetString(Inverted), MouseScrollType.Inverted }, + { FluentProvider.GetString(Joystick), MouseScrollType.Joystick }, }; ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate) @@ -205,11 +205,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var options = new Dictionary() { - { TranslationProvider.GetString(Alt), Modifiers.Alt }, - { TranslationProvider.GetString(Ctrl), Modifiers.Ctrl }, - { TranslationProvider.GetString(Meta), Modifiers.Meta }, - { TranslationProvider.GetString(Shift), Modifiers.Shift }, - { TranslationProvider.GetString(None), Modifiers.None } + { FluentProvider.GetString(Alt), Modifiers.Alt }, + { FluentProvider.GetString(Ctrl), Modifiers.Ctrl }, + { FluentProvider.GetString(Meta), Modifiers.Meta }, + { FluentProvider.GetString(Shift), Modifiers.Shift }, + { FluentProvider.GetString(None), Modifiers.None } }; ScrollItemWidget SetupItem(string o, ScrollItemWidget itemTemplate) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs index 635d3ca064..af500f51e8 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/SettingsLogic.cs @@ -19,37 +19,37 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class SettingsLogic : ChromeLogic { - [TranslationReference] + [FluentReference] const string SettingsSaveTitle = "dialog-settings-save.title"; - [TranslationReference] + [FluentReference] const string SettingsSavePrompt = "dialog-settings-save.prompt"; - [TranslationReference] + [FluentReference] const string SettingsSaveCancel = "dialog-settings-save.cancel"; - [TranslationReference] + [FluentReference] const string RestartTitle = "dialog-settings-restart.title"; - [TranslationReference] + [FluentReference] const string RestartPrompt = "dialog-settings-restart.prompt"; - [TranslationReference] + [FluentReference] const string RestartAccept = "dialog-settings-restart.confirm"; - [TranslationReference] + [FluentReference] const string RestartCancel = "dialog-settings-restart.cancel"; - [TranslationReference("panel")] + [FluentReference("panel")] const string ResetTitle = "dialog-settings-reset.title"; - [TranslationReference] + [FluentReference] const string ResetPrompt = "dialog-settings-reset.prompt"; - [TranslationReference] + [FluentReference] const string ResetAccept = "dialog-settings-reset.confirm"; - [TranslationReference] + [FluentReference] const string ResetCancel = "dialog-settings-reset.cancel"; readonly Dictionary> leavePanelActions = new(); @@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ConfirmationDialogs.ButtonPrompt(modData, title: ResetTitle, text: ResetPrompt, - titleArguments: Translation.Arguments("panel", panels[activePanel]), + titleArguments: FluentBundle.Arguments("panel", panels[activePanel]), onConfirm: Reset, confirmText: ResetAccept, onCancel: () => { }, diff --git a/OpenRA.Mods.Common/Widgets/MapPreviewWidget.cs b/OpenRA.Mods.Common/Widgets/MapPreviewWidget.cs index 457802b33b..7d73dfede3 100644 --- a/OpenRA.Mods.Common/Widgets/MapPreviewWidget.cs +++ b/OpenRA.Mods.Common/Widgets/MapPreviewWidget.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Widgets public SpawnOccupant(Session.Client client) { Color = client.Color; - PlayerName = client.IsBot ? TranslationProvider.GetString(client.Name) : client.Name; + PlayerName = client.IsBot ? FluentProvider.GetString(client.Name) : client.Name; Team = client.Team; Faction = client.Faction; SpawnPoint = client.SpawnPoint; @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Widgets public SpawnOccupant(GameInformation.Player player) { Color = player.Color; - PlayerName = player.IsBot ? TranslationProvider.GetString(player.Name) : player.Name; + PlayerName = player.IsBot ? FluentProvider.GetString(player.Name) : player.Name; Team = player.Team; Faction = player.FactionId; SpawnPoint = player.SpawnPoint; @@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Widgets public SpawnOccupant(GameClient player, bool suppressFaction) { Color = player.Color; - PlayerName = player.IsBot ? TranslationProvider.GetString(player.Name) : player.Name; + PlayerName = player.IsBot ? FluentProvider.GetString(player.Name) : player.Name; Team = player.Team; Faction = !suppressFaction ? player.Faction : null; SpawnPoint = player.SpawnPoint; diff --git a/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs b/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs index 592c68da24..fef6d4440f 100644 --- a/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs @@ -75,10 +75,10 @@ namespace OpenRA.Mods.Common.Widgets public readonly bool DrawTime = true; - [TranslationReference] + [FluentReference] public string ReadyText = ""; - [TranslationReference] + [FluentReference] public string HoldText = ""; public readonly string InfiniteSymbol = "\u221E"; @@ -178,9 +178,9 @@ namespace OpenRA.Mods.Common.Widgets Game.Renderer.Fonts.TryGetValue(SymbolsFont, out symbolFont); iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset; - HoldText = TranslationProvider.GetString(HoldText); + HoldText = FluentProvider.GetString(HoldText); holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2; - ReadyText = TranslationProvider.GetString(ReadyText); + ReadyText = FluentProvider.GetString(ReadyText); readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2; if (ChromeMetrics.TryGet("InfiniteOffset", out infiniteOffset)) diff --git a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs index 9541eeb563..026d7d90bc 100644 --- a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Widgets { public class SupportPowerTimerWidget : Widget { - [TranslationReference("player", "support-power", "time")] + [FluentReference("player", "support-power", "time")] const string Format = "support-power-timer"; public readonly string Font = "Bold"; @@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Widgets { var self = p.Instances[0].Self; var time = WidgetUtils.FormatTime(p.RemainingTicks, false, self.World.Timestep); - var text = TranslationProvider.GetString(Format, Translation.Arguments("player", self.Owner.ResolvedPlayerName, "support-power", p.Name, "time", time)); + var text = FluentProvider.GetString(Format, FluentBundle.Arguments("player", self.Owner.ResolvedPlayerName, "support-power", p.Name, "time", time)); var color = !p.Ready || Game.LocalTick % 50 < 25 ? self.OwnerColor() : Color.White; diff --git a/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs b/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs index 8c0fcd1e70..d683e64761 100644 --- a/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs @@ -22,10 +22,10 @@ namespace OpenRA.Mods.Common.Widgets { public class SupportPowersWidget : Widget { - [TranslationReference] + [FluentReference] public string ReadyText = ""; - [TranslationReference] + [FluentReference] public string HoldText = ""; public readonly string OverlayFont = "TinyBold"; @@ -112,9 +112,9 @@ namespace OpenRA.Mods.Common.Widgets iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset; - HoldText = TranslationProvider.GetString(HoldText); + HoldText = FluentProvider.GetString(HoldText); holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2; - ReadyText = TranslationProvider.GetString(ReadyText); + ReadyText = FluentProvider.GetString(ReadyText); readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2; clock = new Animation(worldRenderer.World, ClockAnimation); diff --git a/OpenRA.Mods.Common/Widgets/WidgetUtils.cs b/OpenRA.Mods.Common/Widgets/WidgetUtils.cs index 589b8e3352..3ce05b5fbf 100644 --- a/OpenRA.Mods.Common/Widgets/WidgetUtils.cs +++ b/OpenRA.Mods.Common/Widgets/WidgetUtils.cs @@ -20,13 +20,13 @@ namespace OpenRA.Mods.Common.Widgets { public static class WidgetUtils { - [TranslationReference] + [FluentReference] const string Gone = "label-client-state-disconnected"; - [TranslationReference] + [FluentReference] const string Won = "label-win-state-won"; - [TranslationReference] + [FluentReference] const string Lost = "label-win-state-lost"; public static string GetStatefulImageName( @@ -339,12 +339,12 @@ namespace OpenRA.Mods.Common.Widgets var suffix = ""; if (c.WinState == WinState.Won) - suffix = $" ({TranslationProvider.GetString(Won)})"; + suffix = $" ({FluentProvider.GetString(Won)})"; else if (c.WinState == WinState.Lost) - suffix = $" ({TranslationProvider.GetString(Lost)})"; + suffix = $" ({FluentProvider.GetString(Lost)})"; if (client.State == Session.ClientState.Disconnected) - suffix = $" ({TranslationProvider.GetString(Gone)})"; + suffix = $" ({FluentProvider.GetString(Gone)})"; text += suffix; diff --git a/OpenRA.Mods.D2k/Traits/AttackSwallow.cs b/OpenRA.Mods.D2k/Traits/AttackSwallow.cs index 3a8d589910..d4ac55f15c 100644 --- a/OpenRA.Mods.D2k/Traits/AttackSwallow.cs +++ b/OpenRA.Mods.D2k/Traits/AttackSwallow.cs @@ -38,7 +38,7 @@ namespace OpenRA.Mods.D2k.Traits [NotificationReference("Speech")] public readonly string WormAttackNotification = "WormAttack"; - [TranslationReference] + [FluentReference] public readonly string WormAttackTextNotification = "notification-worm-attack"; public override object Create(ActorInitializer init) { return new AttackSwallow(init.Self, this); } diff --git a/OpenRA.Server/Program.cs b/OpenRA.Server/Program.cs index 55d4ca66d2..b2a93aab39 100644 --- a/OpenRA.Server/Program.cs +++ b/OpenRA.Server/Program.cs @@ -93,8 +93,8 @@ namespace OpenRA.Server modData.MapCache.LoadPreviewImages = false; // PERF: Server doesn't need previews, save memory by not loading them. modData.MapCache.LoadMaps(); - // HACK: Related to the above one, initialize the translations so we can load maps with their (translated) lobby options. - TranslationProvider.Initialize(modData, modData.DefaultFileSystem); + // HACK: Related to the above one, initialize fluent so we can resolve lobby option ids to strings. + FluentProvider.Initialize(modData, modData.DefaultFileSystem); var endpoints = new List { new(IPAddress.IPv6Any, settings.ListenPort), new(IPAddress.Any, settings.ListenPort) }; var server = new Server(endpoints, settings, modData, ServerType.Dedicated); diff --git a/OpenRA.Test/OpenRA.Game/FluentTest.cs b/OpenRA.Test/OpenRA.Game/FluentTest.cs index 62365a6e11..4119c58626 100644 --- a/OpenRA.Test/OpenRA.Game/FluentTest.cs +++ b/OpenRA.Test/OpenRA.Game/FluentTest.cs @@ -27,10 +27,10 @@ label-players = {$player -> [TestCase(TestName = "Fluent Plural Terms")] public void TestOne() { - var translation = new Translation("en", pluralForms, e => Console.WriteLine(e.Message)); - var label = translation.GetString("label-players", Translation.Arguments("player", 1)); + var bundle = new FluentBundle("en", pluralForms, e => Console.WriteLine(e.Message)); + var label = bundle.GetString("label-players", FluentBundle.Arguments("player", 1)); Assert.That("One player", Is.EqualTo(label)); - label = translation.GetString("label-players", Translation.Arguments("player", 2)); + label = bundle.GetString("label-players", FluentBundle.Arguments("player", 2)); Assert.That("2 players", Is.EqualTo(label)); } }