Extract translation strings.
This commit is contained in:
committed by
Gustas
parent
dfd5a960ed
commit
0b67b5bfae
@@ -19,7 +19,41 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class ServerCreationLogic : ChromeLogic
|
||||
{
|
||||
[TranslationReference]
|
||||
static readonly string InternetServerNatA = "internet-server-nat-A";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string InternetServerNatBenabled = "internet-server-nat-B-enabled";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string InternetServerNatBnotSupported = "internet-server-nat-B-not-supported";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string InternetServerNatBdisabled = "internet-server-nat-B-disabled";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string InternetServerNatC = "internet-server-nat-C";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string LocalServer = "local-server";
|
||||
|
||||
[TranslationReference("port")]
|
||||
static readonly string ServerCreationFailedPrompt = "server-creation-failed-prompt";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string ServerCreationFailedPortUsed = "server-creation-failed-port-used";
|
||||
|
||||
[TranslationReference("message", "code")]
|
||||
static readonly string ServerCreationFailedError = "server-creation-failed-error";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string ServerCreationFailedTitle = "server-creation-failed-title";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string ServerCreationFailedCancel = "server-creation-failed-cancel";
|
||||
|
||||
readonly Widget panel;
|
||||
readonly ModData modData;
|
||||
readonly LabelWidget noticesLabelA, noticesLabelB, noticesLabelC;
|
||||
readonly Action onCreate;
|
||||
readonly Action onExit;
|
||||
@@ -30,6 +64,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public ServerCreationLogic(Widget widget, ModData modData, Action onExit, Action openLobby)
|
||||
{
|
||||
panel = widget;
|
||||
this.modData = modData;
|
||||
onCreate = openLobby;
|
||||
this.onExit = onExit;
|
||||
|
||||
@@ -154,12 +189,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
if (advertiseOnline)
|
||||
{
|
||||
noticesLabelA.Text = "Internet Server (UPnP/NAT-PMP ";
|
||||
noticesLabelA.Text = modData.Translation.GetString(InternetServerNatA) + " ";
|
||||
var aWidth = Game.Renderer.Fonts[noticesLabelA.Font].Measure(noticesLabelA.Text).X;
|
||||
noticesLabelA.Bounds.Width = aWidth;
|
||||
|
||||
noticesLabelB.Text = Nat.Status == NatStatus.Enabled ? "Enabled" :
|
||||
Nat.Status == NatStatus.NotSupported ? "Not Supported" : "Disabled";
|
||||
noticesLabelB.Text = Nat.Status == NatStatus.Enabled ? modData.Translation.GetString(InternetServerNatBenabled) :
|
||||
Nat.Status == NatStatus.NotSupported ? modData.Translation.GetString(InternetServerNatBnotSupported)
|
||||
: modData.Translation.GetString(InternetServerNatBdisabled);
|
||||
|
||||
noticesLabelB.TextColor = Nat.Status == NatStatus.Enabled ? ChromeMetrics.Get<Color>("NoticeSuccessColor") :
|
||||
Nat.Status == NatStatus.NotSupported ? ChromeMetrics.Get<Color>("NoticeErrorColor") :
|
||||
@@ -170,13 +206,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
noticesLabelB.Bounds.Width = bWidth;
|
||||
noticesLabelB.Visible = true;
|
||||
|
||||
noticesLabelC.Text = "):";
|
||||
noticesLabelC.Text = modData.Translation.GetString(InternetServerNatC);
|
||||
noticesLabelC.Bounds.X = noticesLabelB.Bounds.Right;
|
||||
noticesLabelC.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
noticesLabelA.Text = "Local Server:";
|
||||
noticesLabelA.Text = modData.Translation.GetString(LocalServer);
|
||||
noticesLabelB.Visible = false;
|
||||
noticesLabelC.Visible = false;
|
||||
}
|
||||
@@ -212,15 +248,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
catch (System.Net.Sockets.SocketException e)
|
||||
{
|
||||
var message = $"Could not listen on port {Game.Settings.Server.ListenPort}.";
|
||||
var message = modData.Translation.GetString(ServerCreationFailedPrompt, Translation.Arguments("port", Game.Settings.Server.ListenPort));
|
||||
|
||||
// AddressAlreadyInUse (WSAEADDRINUSE)
|
||||
if (e.ErrorCode == 10048)
|
||||
message += "\nCheck if the port is already being used.";
|
||||
message += "\n" + modData.Translation.GetString(ServerCreationFailedPortUsed);
|
||||
else
|
||||
message += $"\nError is: \"{e.Message}\" ({e.ErrorCode})";
|
||||
message += $"\n" + modData.Translation.GetString(ServerCreationFailedError,
|
||||
Translation.Arguments("message", e.Message, "code", e.ErrorCode));
|
||||
|
||||
ConfirmationDialogs.ButtonPrompt("Server Creation Failed", message, onCancel: () => { }, cancelText: "Back");
|
||||
ConfirmationDialogs.ButtonPrompt(modData, ServerCreationFailedTitle, message,
|
||||
onCancel: () => { }, cancelText: ServerCreationFailedCancel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user