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

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

View File

@@ -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<ISourceResolver>($"{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<string, IEnumerable<string>>();
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;

View File

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

View File

@@ -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<LabelWidget>("HEADER_TEMPLATE");