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

@@ -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<LabelWidget>("LABEL").GetText = () => owner;
var ownerDropdown = ownerContainer.Get<DropDownButtonWidget>("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()

View File

@@ -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<EditorOnlyTooltipInfo>().FirstOrDefault(ti => ti.EnabledByDefault) as TooltipInfoBase
?? a.TraitInfos<TooltipInfo>().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<string>() { 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}"));
}

View File

@@ -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<DropDownButtonWidget>("CATEGORIES_DROPDOWN");
categorySelector.GetText = () =>

View File

@@ -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;

View File

@@ -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}'");
}
};

View File

@@ -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<LabelWidget>("LABEL").GetText = () => TranslationProvider.GetString(toolNames[tool]);
item.Get<LabelWidget>("LABEL").GetText = () => FluentProvider.GetString(toolNames[tool]);
return item;
}

View File

@@ -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, MapFileTypeInfo>()
{
{ 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<DropDownButtonWidget>("TYPE_DROPDOWN");