Statistics = new();
@@ -30,6 +30,8 @@ public class AdminPanelPage : BaseLayout
this.Statistics.Add(new AdminPanelStatistic("Users", await StatisticsHelper.UserCount(), "/admin/users"));
this.Statistics.Add(new AdminPanelStatistic("Slots", await StatisticsHelper.SlotCount()));
this.Statistics.Add(new AdminPanelStatistic("Photos", await StatisticsHelper.PhotoCount()));
+ this.Statistics.Add(new AdminPanelStatistic("Reports", await StatisticsHelper.ReportCount(), "/admin/reports/0"));
+ this.Statistics.Add(new AdminPanelStatistic("API Keys", await StatisticsHelper.APIKeyCount(), "/admin/keys"));
if (!string.IsNullOrEmpty(command))
{
diff --git a/ProjectLighthouse.Servers.Website/Pages/Admin/ReportsPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/Admin/ReportsPage.cshtml
index ecbe7ac8..05f5c788 100644
--- a/ProjectLighthouse.Servers.Website/Pages/Admin/ReportsPage.cshtml
+++ b/ProjectLighthouse.Servers.Website/Pages/Admin/ReportsPage.cshtml
@@ -11,7 +11,7 @@
diff --git a/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml
index 9845e193..f8b81b74 100644
--- a/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml
+++ b/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml
@@ -44,6 +44,10 @@
Create Fake Room
+
+ Create Rooms With Duplicate Players
+
+
Nuke all rooms
diff --git a/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml
index c881ae1e..60dbddf0 100644
--- a/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml
+++ b/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml
@@ -3,6 +3,7 @@
@using LBPUnion.ProjectLighthouse.Extensions
@using LBPUnion.ProjectLighthouse.PlayerData.Profiles
@using LBPUnion.ProjectLighthouse.Levels
+@using LBPUnion.ProjectLighthouse.Localization.StringLists
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.LandingPage
@{
@@ -10,22 +11,22 @@
Model.ShowTitleInPage = false;
bool isMobile = this.Request.IsMobile();
}
-Welcome to @ServerConfiguration.Instance.Customization.ServerName!
+@Model.Translate(LandingPageStrings.Welcome, ServerConfiguration.Instance.Customization.ServerName)
@if (Model.User != null)
{
- You are currently logged in as @Model.User.Username.
- if (ServerConfiguration.Instance.Authentication.UseExternalAuth && Model.AuthenticationAttemptsCount > 0)
+ @Model.Translate(LandingPageStrings.LoggedInAs, Model.User.Username)
+ if (ServerConfiguration.Instance.Authentication.UseExternalAuth && Model.PendingAuthAttempts > 0)
{
- You have @Model.AuthenticationAttemptsCount authentication attempts pending. Click here to view them.
+ @Model.Translate(LandingPageStrings.AuthAttemptsPending, Model.PendingAuthAttempts)
}
}
@if (Model.PlayersOnlineCount == 1)
{
- There is 1 user currently online:
+ @Model.Translate(LandingPageStrings.UsersSingle)
@foreach (User user in Model.PlayersOnline)
{
@user.Username
@@ -34,11 +35,11 @@
else if (Model.PlayersOnlineCount == 0)
{
- There are no users online. Why not hop on?
+ @Model.Translate(LandingPageStrings.UsersNone)
}
else
{
- There are currently @Model.PlayersOnlineCount users online:
+ @Model.Translate(LandingPageStrings.UsersMultiple, Model.PlayersOnlineCount)
@foreach (User user in Model.PlayersOnline)
{
@user.Username
@@ -50,7 +51,7 @@ else
-
Latest Team Picks
+
@Model.Translate(LandingPageStrings.LatestTeamPicks)
@foreach (Slot slot in Model.LatestTeamPicks!) @* Can't reach a point where this is null *@
@@ -67,7 +68,7 @@ else
}
-
Newest Levels
+
@Model.Translate(LandingPageStrings.NewestLevels)
@foreach (Slot slot in Model.NewestLevels!) @* Can't reach a point where this is null *@
diff --git a/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml.cs
index 20b13dbc..fecee91b 100644
--- a/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml.cs
+++ b/ProjectLighthouse.Servers.Website/Pages/LandingPage.cshtml.cs
@@ -15,7 +15,7 @@ public class LandingPage : BaseLayout
public LandingPage(Database database) : base(database)
{}
- public int AuthenticationAttemptsCount;
+ public int PendingAuthAttempts;
public List
PlayersOnline = new();
public int PlayersOnlineCount;
@@ -32,7 +32,7 @@ public class LandingPage : BaseLayout
this.PlayersOnlineCount = await StatisticsHelper.RecentMatches();
if (user != null)
- this.AuthenticationAttemptsCount = await this.Database.AuthenticationAttempts.Include
+ this.PendingAuthAttempts = await this.Database.AuthenticationAttempts.Include
(a => a.GameToken)
.CountAsync(a => a.GameToken.UserId == user.UserId);
diff --git a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml
index d01032fb..d6da5335 100644
--- a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml
+++ b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml
@@ -1,31 +1,32 @@
@using LBPUnion.ProjectLighthouse.Configuration
@using LBPUnion.ProjectLighthouse.Extensions
@using LBPUnion.ProjectLighthouse.Helpers
+@using LBPUnion.ProjectLighthouse.Localization.StringLists
@using LBPUnion.ProjectLighthouse.Types
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts.BaseLayout
@{
if (Model!.User == null)
{
- Model.NavigationItemsRight.Add(new PageNavigationItem("Login / Register", "/login", "sign in"));
+ Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderLoginRegister, "/login", "sign in"));
}
else
{
if (ServerConfiguration.Instance.Authentication.UseExternalAuth)
{
- Model.NavigationItems.Add(new PageNavigationItem("Authentication", "/authentication", "key"));
+ Model.NavigationItems.Add(new PageNavigationItem(BaseLayoutStrings.HeaderAuthentication, "/authentication", "key"));
}
- Model.NavigationItemsRight.Add(new PageNavigationItem("Profile", "/user/" + Model.User.UserId, "user alternate"));
+ Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderProfile, "/user/" + Model.User.UserId, "user alternate"));
@if (Model.User.IsAdmin)
{
- Model.NavigationItemsRight.Add(new PageNavigationItem("Admin Panel", "/admin", "cogs"));
+ Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderAdminPanel, "/admin", "cogs"));
}
- else if(Model.User.IsModerator)
+ else if (Model.User.IsModerator)
{
- Model.NavigationItemsRight.Add(new PageNavigationItem("Mod Panel", "/moderation", "user shield"));
+ Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderModPanel, "/moderation", "user shield"));
}
- Model.NavigationItemsRight.Add(new PageNavigationItem("Log out", "/logout", "user alternate slash")); // should always be last
+ Model.NavigationItemsRight.Add(new PageNavigationItem(BaseLayoutStrings.HeaderLogout, "/logout", "user alternate slash")); // should always be last
}
Model.IsMobile = Model.Request.IsMobile();
@@ -99,7 +100,7 @@
@if (!Model.IsMobile)
{
- @navigationItem.Name
+ @Model.Translate(navigationItem.Name)
}
}
@@ -114,7 +115,7 @@
@if (!Model.IsMobile)
{
- @navigationItem.Name
+ @Model.Translate(navigationItem.Name)
}
}
diff --git a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs
index 991692da..3537e4cb 100644
--- a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs
+++ b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs
@@ -1,22 +1,21 @@
#nullable enable
+using System;
+using System.Collections.Generic;
+using LBPUnion.ProjectLighthouse.Configuration;
+using LBPUnion.ProjectLighthouse.Localization;
+using LBPUnion.ProjectLighthouse.Localization.StringLists;
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
using LBPUnion.ProjectLighthouse.Types;
+using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
public class BaseLayout : PageModel
{
-
public readonly Database Database;
- public readonly List NavigationItems = new()
- {
- new PageNavigationItem("Home", "/", "home"),
- new PageNavigationItem("Users", "/users/0", "user friends"),
- new PageNavigationItem("Photos", "/photos/0", "camera"),
- new PageNavigationItem("Levels", "/slots/0", "certificate"),
- };
+ public readonly List NavigationItems = new();
public readonly List NavigationItemsRight = new();
public string Description = string.Empty;
@@ -31,6 +30,11 @@ public class BaseLayout : PageModel
public BaseLayout(Database database)
{
this.Database = database;
+
+ this.NavigationItems.Add(new PageNavigationItem(BaseLayoutStrings.HeaderHome, "/", "home"));
+ this.NavigationItems.Add(new PageNavigationItem(BaseLayoutStrings.HeaderUsers, "/users/0", "user friends"));
+ this.NavigationItems.Add(new PageNavigationItem(BaseLayoutStrings.HeaderPhotos, "/photos/0", "camera"));
+ this.NavigationItems.Add(new PageNavigationItem(BaseLayoutStrings.HeaderSlots, "/slots/0", "certificate"));
}
public new User? User {
@@ -41,4 +45,17 @@ public class BaseLayout : PageModel
}
set => this.user = value;
}
+
+ private string getLanguage()
+ {
+ if (ServerStatics.IsUnitTesting) return "en-US";
+
+ IRequestCultureFeature? requestCulture = Request.HttpContext.Features.Get();
+
+ if (requestCulture == null) return LocalizationManager.DefaultLang;
+ return requestCulture.RequestCulture.UICulture.Name;
+ }
+
+ public string Translate(TranslatableString translatableString) => translatableString.Translate(this.getLanguage());
+ public string Translate(TranslatableString translatableString, params object?[] format) => translatableString.Translate(this.getLanguage(), format);
}
\ No newline at end of file
diff --git a/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml b/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml
index 9dd0dfa0..cedbbdc7 100644
--- a/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml
+++ b/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml
@@ -1,21 +1,27 @@
@page "/login"
@using LBPUnion.ProjectLighthouse.Configuration
+@using LBPUnion.ProjectLighthouse.Localization.StringLists
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.LoginForm
@{
Layout = "Layouts/BaseLayout";
- Model.Title = "Log in";
+ Model.Title = Model.Translate(GeneralStrings.LogIn);
}
@@ -24,7 +30,7 @@
{
@@ -32,19 +38,20 @@