mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 18:11:27 -07:00
Localize server location notifications
This commit is contained in:
parent
3fc1ff443f
commit
13f2690084
13
Bloxstrap/Extensions/ServerTypeEx.cs
Normal file
13
Bloxstrap/Extensions/ServerTypeEx.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace Bloxstrap.Extensions
|
||||||
|
{
|
||||||
|
static class ServerTypeEx
|
||||||
|
{
|
||||||
|
public static string ToTranslatedString(this ServerType value) => value switch
|
||||||
|
{
|
||||||
|
ServerType.Public => Resources.Strings.Enums_ServerType_Public,
|
||||||
|
ServerType.Private => Resources.Strings.Enums_ServerType_Private,
|
||||||
|
ServerType.Reserved => Resources.Strings.Enums_ServerType_Reserved,
|
||||||
|
_ => "?"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -294,17 +294,17 @@
|
|||||||
var ipInfo = await Http.GetJson<IPInfoResponse>($"https://ipinfo.io/{ActivityMachineAddress}/json");
|
var ipInfo = await Http.GetJson<IPInfoResponse>($"https://ipinfo.io/{ActivityMachineAddress}/json");
|
||||||
|
|
||||||
if (ipInfo is null)
|
if (ipInfo is null)
|
||||||
return $"N/A ({Resources.Strings.ActivityTracker_LookupFailed})";
|
return $"? ({Resources.Strings.ActivityTracker_LookupFailed})";
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(ipInfo.Country))
|
if (string.IsNullOrEmpty(ipInfo.Country))
|
||||||
location = "N/A";
|
location = "?";
|
||||||
else if (ipInfo.City == ipInfo.Region)
|
else if (ipInfo.City == ipInfo.Region)
|
||||||
location = $"{ipInfo.Region}, {ipInfo.Country}";
|
location = $"{ipInfo.Region}, {ipInfo.Country}";
|
||||||
else
|
else
|
||||||
location = $"{ipInfo.City}, {ipInfo.Region}, {ipInfo.Country}";
|
location = $"{ipInfo.City}, {ipInfo.Region}, {ipInfo.Country}";
|
||||||
|
|
||||||
if (!ActivityInGame)
|
if (!ActivityInGame)
|
||||||
return $"N/A ({Resources.Strings.ActivityTracker_LeftGame})";
|
return $"? ({Resources.Strings.ActivityTracker_LeftGame})";
|
||||||
|
|
||||||
GeolocationCache[ActivityMachineAddress] = location;
|
GeolocationCache[ActivityMachineAddress] = location;
|
||||||
|
|
||||||
@ -315,7 +315,7 @@
|
|||||||
App.Logger.WriteLine(LOG_IDENT, $"Failed to get server location for {ActivityMachineAddress}");
|
App.Logger.WriteLine(LOG_IDENT, $"Failed to get server location for {ActivityMachineAddress}");
|
||||||
App.Logger.WriteException(LOG_IDENT, ex);
|
App.Logger.WriteException(LOG_IDENT, ex);
|
||||||
|
|
||||||
return $"N/A ({Resources.Strings.ActivityTracker_LookupFailed})";
|
return $"? ({Resources.Strings.ActivityTracker_LookupFailed})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
Bloxstrap/Resources/Strings.Designer.cs
generated
19
Bloxstrap/Resources/Strings.Designer.cs
generated
@ -548,6 +548,25 @@ namespace Bloxstrap.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Located at {0}
|
||||||
|
///Click for more information.
|
||||||
|
/// </summary>
|
||||||
|
public static string ContextMenu_ServerInformation_Notification_Text {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ContextMenu.ServerInformation.Notification.Text", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Connected to {0} server.
|
||||||
|
/// </summary>
|
||||||
|
public static string ContextMenu_ServerInformation_Notification_Title {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ContextMenu.ServerInformation.Notification.Title", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Server information.
|
/// Looks up a localized string similar to Server information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -283,6 +283,14 @@ Your ReShade configuration files will still be saved, and you can locate them by
|
|||||||
<data name="ContextMenu.ServerInformation.Location" xml:space="preserve">
|
<data name="ContextMenu.ServerInformation.Location" xml:space="preserve">
|
||||||
<value>Location</value>
|
<value>Location</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ContextMenu.ServerInformation.Notification.Text" xml:space="preserve">
|
||||||
|
<value>Located at {0}
|
||||||
|
Click for more information</value>
|
||||||
|
</data>
|
||||||
|
<data name="ContextMenu.ServerInformation.Notification.Title" xml:space="preserve">
|
||||||
|
<value>Connected to {0} server</value>
|
||||||
|
<comment>Enums.ServerType fills in {0} and is dynamically converted to lowercase when inserted here</comment>
|
||||||
|
</data>
|
||||||
<data name="ContextMenu.ServerInformation.Title" xml:space="preserve">
|
<data name="ContextMenu.ServerInformation.Title" xml:space="preserve">
|
||||||
<value>Server information</value>
|
<value>Server information</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System.Windows;
|
using Bloxstrap.Integrations;
|
||||||
|
|
||||||
using Bloxstrap.Integrations;
|
|
||||||
using Bloxstrap.UI.Elements.ContextMenu;
|
using Bloxstrap.UI.Elements.ContextMenu;
|
||||||
|
|
||||||
namespace Bloxstrap.UI
|
namespace Bloxstrap.UI
|
||||||
@ -91,8 +89,8 @@ namespace Bloxstrap.UI
|
|||||||
string serverLocation = await _activityWatcher!.GetServerLocation();
|
string serverLocation = await _activityWatcher!.GetServerLocation();
|
||||||
|
|
||||||
ShowAlert(
|
ShowAlert(
|
||||||
$"Connected to {_activityWatcher.ActivityServerType.ToString().ToLower()} server",
|
String.Format(Resources.Strings.ContextMenu_ServerInformation_Notification_Title, _activityWatcher.ActivityServerType.ToTranslatedString().ToLower()),
|
||||||
$"Located at {serverLocation}\nClick for more information",
|
String.Format(Resources.Strings.ContextMenu_ServerInformation_Notification_Text, serverLocation),
|
||||||
10,
|
10,
|
||||||
(_, _) => _menuContainer?.ShowServerInformationWindow()
|
(_, _) => _menuContainer?.ShowServerInformationWindow()
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user