Rename Fluent-related code to be more precise.

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

View File

@@ -16,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<bool> okPressed, Action cancelPressed)
{
var kickMessage = TranslationProvider.GetString(KickClient, Translation.Arguments("player", clientName));
var kickMessage = FluentProvider.GetString(KickClient, FluentBundle.Arguments("player", clientName));
widget.Get<LabelWidget>("TITLE").GetText = () => kickMessage;
var tempBan = false;

View File

@@ -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<LabelWidget>("TEXT").GetText = () => kickMessage;
widget.Get<ButtonWidget>("OK_BUTTON").OnClick = () =>

View File

@@ -23,40 +23,40 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
public class LobbyLogic : ChromeLogic, INotificationHandler<TextNotification>
{
[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<ButtonWidget>("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<int, string>(x => TranslationProvider.GetString(ChatAvailability, Translation.Arguments("seconds", x)));
chatDisabled = TranslationProvider.GetString(ChatDisabled);
chatAvailableIn = new CachedTransform<int, string>(x => FluentProvider.GetString(ChatAvailability, FluentBundle.Arguments("seconds", x)));
chatDisabled = FluentProvider.GetString(ChatDisabled);
lobbyChatPanel = lobby.Get<ScrollPanelWidget>("CHAT_DISPLAY");
lobbyChatPanel.RemoveChildren();

View File

@@ -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<string, string>(id =>
{
if (id == null || !option.Values.TryGetValue(id, out var value))
return TranslationProvider.GetString(NotAvailable);
return FluentProvider.GetString(NotAvailable);
return value;
});

View File

@@ -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<string, IEnumerable<SlotDropDownOption>>
{
{
TranslationProvider.GetString(Slot), new List<SlotDropDownOption>
FluentProvider.GetString(Slot), new List<SlotDropDownOption>
{
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<IBotInfo>())
{
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<LabelWidget>("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<ImageWidget>("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<LabelWidget>("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<LabelWidget>("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<LabelWidget>("FACTIONNAME");
var font = Game.Renderer.Fonts[factionName.Font];
var truncated = new CachedTransform<string, string>(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<ImageWidget>("FACTIONFLAG");

View File

@@ -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<string, string>(
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"));

View File

@@ -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<int, string> teamMessage;
@@ -49,9 +49,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var labelText = "";
string playerFaction = null;
var playerTeam = -1;
teamMessage = new CachedTransform<int, string>(t => TranslationProvider.GetString(TeamNumber, Translation.Arguments("team", t)));
var disabledSpawn = TranslationProvider.GetString(DisabledSpawn);
var availableSpawn = TranslationProvider.GetString(AvailableSpawn);
teamMessage = new CachedTransform<int, string>(t => FluentProvider.GetString(TeamNumber, FluentBundle.Arguments("team", t)));
var disabledSpawn = FluentProvider.GetString(DisabledSpawn);
var availableSpawn = FluentProvider.GetString(AvailableSpawn);
tooltipContainer.BeforeRender = () =>
{