Add TranslationProvider

This commit is contained in:
Matthias Mailänder
2023-04-13 17:14:01 +03:00
committed by Matthias Mailänder
parent a065e6a47c
commit 68eec52cef
66 changed files with 384 additions and 333 deletions

View File

@@ -36,11 +36,11 @@ namespace OpenRA.Mods.Common.Widgets
var cancelButton = prompt.GetOrNull<ButtonWidget>("CANCEL_BUTTON");
var otherButton = prompt.GetOrNull<ButtonWidget>("OTHER_BUTTON");
var titleMessage = modData.Translation.GetString(title, titleArguments);
var titleMessage = TranslationProvider.GetString(title, titleArguments);
prompt.Get<LabelWidget>("PROMPT_TITLE").GetText = () => titleMessage;
var headerTemplate = prompt.Get<LabelWidget>("PROMPT_TEXT");
var textMessage = modData.Translation.GetString(text, textArguments);
var textMessage = TranslationProvider.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 = modData.Translation.GetString(confirmText);
var confirmTextMessage = TranslationProvider.GetString(confirmText);
confirmButton.GetText = () => confirmTextMessage;
}
}
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Widgets
if (!string.IsNullOrEmpty(cancelText))
{
var cancelTextMessage = modData.Translation.GetString(cancelText);
var cancelTextMessage = TranslationProvider.GetString(cancelText);
cancelButton.GetText = () => cancelTextMessage;
}
}
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Widgets
if (!string.IsNullOrEmpty(otherText))
{
var otherTextMessage = modData.Translation.GetString(otherText);
var otherTextMessage = TranslationProvider.GetString(otherText);
otherButton.GetText = () => otherTextMessage;
}
}
@@ -114,10 +114,10 @@ namespace OpenRA.Mods.Common.Widgets
Func<bool> doValidate = null;
ButtonWidget acceptButton = null, cancelButton = null;
var titleMessage = modData.Translation.GetString(title);
var titleMessage = TranslationProvider.GetString(title);
panel.Get<LabelWidget>("PROMPT_TITLE").GetText = () => titleMessage;
var promptMessage = modData.Translation.GetString(prompt);
var promptMessage = TranslationProvider.GetString(prompt);
panel.Get<LabelWidget>("PROMPT_TEXT").GetText = () => promptMessage;
var input = panel.Get<TextFieldWidget>("INPUT_TEXT");
@@ -147,7 +147,7 @@ namespace OpenRA.Mods.Common.Widgets
acceptButton = panel.Get<ButtonWidget>("ACCEPT_BUTTON");
if (!string.IsNullOrEmpty(acceptText))
{
var acceptTextMessage = modData.Translation.GetString(acceptText);
var acceptTextMessage = TranslationProvider.GetString(acceptText);
acceptButton.GetText = () => acceptTextMessage;
}
@@ -163,7 +163,7 @@ namespace OpenRA.Mods.Common.Widgets
cancelButton = panel.Get<ButtonWidget>("CANCEL_BUTTON");
if (!string.IsNullOrEmpty(cancelText))
{
var cancelTextMessage = modData.Translation.GetString(cancelText);
var cancelTextMessage = TranslationProvider.GetString(cancelText);
cancelButton.GetText = () => cancelTextMessage;
}