add translation for webfront

discord link has been genericized to social link
This commit is contained in:
RaidMax
2018-05-05 17:52:04 -05:00
parent e8dff01c41
commit a54ea3913d
22 changed files with 259 additions and 84 deletions

View File

@ -83,12 +83,12 @@ namespace WebfrontCore.Controllers
new InputInfo()
{
Name = "clientId",
Label = "Client ID"
Label = Localization["WEBFRONT_ACTION_LABEL_ID"]
},
new InputInfo()
{
Name = "Password",
Label ="Password",
Label = Localization["WEBFRONT_ACTION_LABEL_PASSWORD"],
Type = "password",
}
},

View File

@ -20,18 +20,21 @@ namespace WebfrontCore.Controllers
protected SharedLibraryCore.Localization.Index Localization { get; private set; }
protected EFClient Client { get; private set; }
private static byte[] LocalHost = { 127, 0, 0, 1 };
private static string DiscordLink;
private static string SocialLink;
private static string SocialTitle;
public BaseController()
{
Manager = Program.Manager;
if (Manager.GetApplicationSettings().Configuration().EnableDiscordLink)
if (Manager == null)
Manager = Program.Manager;
if (Localization == null)
Localization = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex;
if (Manager.GetApplicationSettings().Configuration().EnableDiscordLink && SocialLink == null)
{
string inviteLink = Manager.GetApplicationSettings().Configuration().DiscordInviteCode;
if (inviteLink != null)
DiscordLink = inviteLink.Contains("https") ? inviteLink : $"https://discordapp.com/invite/{inviteLink}";
else
DiscordLink = "";
SocialLink = Manager.GetApplicationSettings().Configuration().DiscordInviteCode;
SocialTitle = Manager.GetApplicationSettings().Configuration().SocialLinkTitle;
}
}
@ -83,7 +86,8 @@ namespace WebfrontCore.Controllers
ViewBag.Authorized = Authorized;
ViewBag.Url = Manager.GetApplicationSettings().Configuration().WebfrontBindUrl;
ViewBag.User = Client;
ViewBag.DiscordLink = DiscordLink ?? "";
ViewBag.SocialLink = SocialLink ?? "";
ViewBag.SocialTitle = SocialTitle;
base.OnActionExecuting(context);
}

View File

@ -53,8 +53,8 @@ namespace WebfrontCore.Controllers
if (Authorized && client.Level > SharedLibraryCore.Objects.Player.Permission.Trusted)
clientDto.Meta.Add(new ProfileMeta()
{
Key = "Masked",
Value = client.Masked ? "Is" : "Is not",
Key = Localization["WEBFRONT_CLIENT_META_MASKED"],
Value = client.Masked ? Localization["WEBFRONT_CLIENT_META_TRUE"]: Localization["WEBFRONT_CLIENT_META_FALSE"],
Sensitive = true,
When = DateTime.MinValue
});
@ -67,7 +67,7 @@ namespace WebfrontCore.Controllers
.Select(a => new ProfileMeta()
{
Key = "AliasEvent",
Value = $"Joined with alias {a.Name}",
Value = $"{Localization["WEBFRONT_CLIENT_META_JOINED"]} {a.Name}",
Sensitive = true,
When = a.DateAdded
}));
@ -83,7 +83,7 @@ namespace WebfrontCore.Controllers
ViewBag.Title = clientDto.Name.Substring(clientDto.Name.Length - 1).ToLower()[0] == 's' ?
clientDto.Name + "'" :
clientDto.Name + "'s";
ViewBag.Title += " Profile";
ViewBag.Title += " " + Localization["WEBFRONT_CLIENT_PROFILE_TITLE"];
ViewBag.Description = $"Client information for {clientDto.Name}";
ViewBag.Keywords = $"IW4MAdmin, client, profile, {clientDto.Name}";
@ -109,7 +109,7 @@ namespace WebfrontCore.Controllers
});
}
ViewBag.Title = "Privileged Clients";
ViewBag.Title = Localization["WEBFRONT_CLIENT_PRIVILEGED_TITLE"];
ViewBag.Description = "List of all privileged clients on IW4MAdmin";
ViewBag.Keywords = "IW4MAdmin, privileged, admins, clients, administrators";
@ -131,7 +131,7 @@ namespace WebfrontCore.Controllers
})
.ToList();
ViewBag.Title = $"{clientsDto.Count} Clients Matching \"{clientName}\"";
ViewBag.Title = $"{clientsDto.Count} {Localization["WEBFRONT_CLIENT_SEARCH_MATCHING"]} \"{clientName}\"";
return View("Find/Index", clientsDto);
}
}

View File

@ -20,7 +20,7 @@ namespace WebfrontCore.Controllers
});
ViewBag.Description = "Use the IW4MAdmin web console to execute commands";
ViewBag.Title = "Web Console";
ViewBag.Title = Localization["WEBFRONT_CONSOLE_TITLE"];
ViewBag.Keywords = "IW4MAdmin, console, execute, commands";
return View(activeServers);

View File

@ -13,7 +13,7 @@ namespace WebfrontCore.Controllers
public IActionResult Index()
{
ViewBag.Description = "IW4MAdmin is a complete server administration tool for IW4x.";
ViewBag.Title = "Server Overview";
ViewBag.Title = Localization["WEBFRONT_HOME_TITLE"];
ViewBag.Keywords = "IW4MAdmin, server, administration, IW4x, MW2, Modern Warfare 2";
return View();
@ -21,8 +21,8 @@ namespace WebfrontCore.Controllers
public IActionResult Error()
{
ViewBag.Description = "IW4MAdmin encountered an error";
ViewBag.Title = "Error!";
ViewBag.Description = Localization["WEBFRONT_ERROR_DESC"];
ViewBag.Title = Localization["WEBFRONT_ERROR_TITLE"];
return View();
}
}

View File

@ -16,7 +16,7 @@ namespace WebfrontCore.Controllers
public IActionResult List(int showOnly = (int)SharedLibraryCore.Objects.Penalty.PenaltyType.Any)
{
ViewBag.Description = "List of all the recent penalties (bans, kicks, warnings) on IW4MAdmin";
ViewBag.Title = "Client Penalties";
ViewBag.Title = Localization["WEBFRONT_PENALTY_TITLE"];
ViewBag.Keywords = "IW4MAdmin, penalties, ban, kick, warns";
return View((SharedLibraryCore.Objects.Penalty.PenaltyType)showOnly);

View File

@ -1,11 +1,14 @@
@model List<SharedLibraryCore.Dtos.PlayerInfo>
@{
var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex;
}
<div class="mr-auto ml-auto col-12 col-lg-7 border-bottom">
<h4 class="pb-2 text-center ">@ViewBag.Title</h4>
<div class="row pt-2 pb-2 bg-primary">
<div class="col-5 ">Name </div>
<div class="col-4">Level</div>
<div class="col-3 text-right">Last Seen</div>
<div class="col-5 ">@loc["WEBFRONT_PENALTY_TEMPLATE_NAME"]</div>
<div class="col-4">@loc["WEBFRONT_PROFILE_LEVEL"]</div>
<div class="col-3 text-right">@loc["WEBFRONT_PROFILE_LSEEN"]</div>
</div>
@{
@ -14,7 +17,7 @@
<div class="row pt-2 pb-2 bg-dark">
<div class="col-5">@Html.ActionLink(client.Name, "ProfileAsync", "Client", new { id = client.ClientId })</div>
<div class="col-4 level-color-@client.Level.ToLower()">@client.Level</div>
<div class="col-3 text-right">@client.LastSeen ago</div>
<div class="col-3 text-right">@client.LastSeen @loc["WEBFRONT_PENALTY_TEMPLATE_AGO"]</div>
</div>
}
}

View File

@ -2,6 +2,7 @@
@{
string match = System.Text.RegularExpressions.Regex.Match(Model.Name.ToUpper(), "[A-Z]").Value;
string shortCode = match == string.Empty ? "?" : match;
var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex;
}
<div id="profile_wrapper" class="row d-flex d-sm-inline-flex justify-content-center justify-content-left pb-3">
<div class="mr-auto ml-auto ml-sm-0 mr-sm-0">
@ -30,13 +31,13 @@
<div id="profile_aliases_btn" class="oi oi-caret-bottom h3 ml-0 ml-md-2"></div>
@if (Model.LevelInt < (int)ViewBag.User.Level &&
(SharedLibraryCore.Objects.Player.Permission)Model.LevelInt != SharedLibraryCore.Objects.Player.Permission.Banned)
(SharedLibraryCore.Objects.Player.Permission)Model.LevelInt != SharedLibraryCore.Objects.Player.Permission.Banned)
{
<div id="profile_action_ban_btn" class="profile-action oi oi-lock-unlocked text-success h3 ml-2" title="Ban Client" data-action="ban" aria-hidden="true"></div>
}
@if (Model.LevelInt < (int)ViewBag.User.Level &&
(SharedLibraryCore.Objects.Player.Permission)Model.LevelInt == SharedLibraryCore.Objects.Player.Permission.Banned)
(SharedLibraryCore.Objects.Player.Permission)Model.LevelInt == SharedLibraryCore.Objects.Player.Permission.Banned)
{
<div id="profile_action_unban_btn" class="profile-action oi oi-lock-locked text-danger h3 ml-2" title="Unban Client" data-action="unban" aria-hidden="true"></div>
}
@ -44,6 +45,7 @@
<div id="profile_aliases" class="pr-0 pr-sm-4 pb-2 mb-2 text-muted order-0">
@{
@Model.NetworkId.ToString("X") <br/>
foreach (string alias in Model.Aliases)
{
@alias <br />
@ -65,13 +67,13 @@
<h5><span class="level-color-@Model.Level.ToLower()"><strong>@Model.Level</strong></span></h5>
</div>
<div id="profile_time_played" class="text-muted">
Played <span class="text-primary">@Model.TimePlayed</span> hours
@loc["WEBFRONT_PROFILE_PLAYER"] <span class="text-primary">@Model.TimePlayed</span> @loc["GLOBAL_HOURS"]
</div>
<div id="profile_first_seen" class="text-muted">
First seen <span class="text-primary">@Model.FirstSeen</span> ago
@loc["WEBFRONT_PROFILE_FSEEN"] <span class="text-primary">@Model.FirstSeen</span> @loc["WEBFRONT_PENALTY_TEMPLATE_AGO"]
</div>
<div id="profile_last_seen" class="text-muted">
Last seen <span class="text-primary">@Model.LastSeen</span> ago
@loc["WEBFRONT_PROFILE_LSEEN"] <span class="text-primary">@Model.LastSeen</span> @loc["WEBFRONT_PENALTY_TEMPLATE_AGO"]
</div>
</div>
<div id="profile_meta" class="text-center text-sm-right pt-2 mt-md-4 pt-md-3 mr-4 pr-4 mr-md-0 ml-4 pl-4 ml-md-0 pr-md-0 pl-md-0">
@ -81,12 +83,6 @@
<div class="row d-md-flex pt-2">
<div id="profile_events" class="text-muted text-left ml-sm-0">
@{
if (Model.Meta.Count == 0)
{
<span> No recent events</span>
}
}
</div>
</div>

View File

@ -10,7 +10,7 @@
<input id="console_command_value" class="form-control m-0 bg-dark text-light" type="text" />
</div>
<div class="col pl-1 pl-sm-0">
<button id="console_command_button" class="btn btn-primary btn-block m-0">Execute</button>
<button id="console_command_button" class="btn btn-primary btn-block m-0">@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CONSOLE_EXECUTE"]</button>
</div>
</div>
</div>

View File

@ -1,5 +1,7 @@
@model SharedLibraryCore.Objects.Penalty.PenaltyType
@{
var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex;
}
<h4 class="pb-2 text-center ">@ViewBag.Title</h4>
<div class="row">
<select class="form-control bg-dark text-muted" id="penalty_filter_selection">
@ -10,22 +12,22 @@
{
if (Model == SharedLibraryCore.Objects.Penalty.PenaltyType.Any)
{
<option value="@Convert.ToInt32(penaltyType)" selected="selected" )>Show @penaltyType.ToString()</option>
<option value="@Convert.ToInt32(penaltyType)" selected="selected" )>@loc["WEBFRONT_PENALTY_TEMPLATE_SHOW"] @penaltyType.ToString()</option>
}
else
{
<option value="@Convert.ToInt32(penaltyType)" )>Show @penaltyType.ToString()</option>
<option value="@Convert.ToInt32(penaltyType)" )>@loc["WEBFRONT_PENALTY_TEMPLATE_SHOW"] @penaltyType.ToString()</option>
}
}
else
{
if ((SharedLibraryCore.Objects.Penalty.PenaltyType)penaltyType == Model)
{
<option value="@Convert.ToInt32(penaltyType)" selected="selected">Show only @penaltyType.ToString()s</option>
<option value="@Convert.ToInt32(penaltyType)" selected="selected">@loc["WEBFRONT_PENALTY_TEMPLATE_SHOWONLY"] @penaltyType.ToString()s</option>
}
else
{
<option value="@Convert.ToInt32(penaltyType)" )>Show only @penaltyType.ToString()s</option>
<option value="@Convert.ToInt32(penaltyType)" )>@loc["WEBFRONT_PENALTY_TEMPLATE_SHOWONLY"] @penaltyType.ToString()s</option>
}
}
}
@ -36,11 +38,11 @@
<table class="table table-striped">
<thead class="d-none d-md-table-header-group">
<tr class="bg-primary pt-2 pb-2">
<th scope="col">Name</th>
<th scope="col">Type</th>
<th scope="col">Offense</th>
<th scope="col">Admin</th>
<th scope="col" class="text-right">Time/Left</th>
<th scope="col">@loc["WEBFRONT_PENALTY_TEMPLATE_NAME"]</th>
<th scope="col">@loc["WEBFRONT_PENALTY_TEMPLATE_TYPE"]</th>
<th scope="col">@loc["WEBFRONT_PENALTY_TEMPLATE_OFFENSE"]</th>
<th scope="col">@loc["WEBFRONT_PENALTY_TEMPLATE_ADMIN"]</th>
<th scope="col" class="text-right">@loc["WEBFRONT_PENALTY_TEMPLATE_TIME"]</th>
</tr>
</thead>
<tbody id="penalty_table" class="border-bottom bg-dark">

View File

@ -1,48 +1,49 @@
@{
Layout = null;
var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex;
}
@model SharedLibraryCore.Dtos.PenaltyInfo
<tr class="d-table-row d-md-none bg-dark">
<th scope="row" class="bg-primary">Name</th>
<th scope="row" class="bg-primary">@loc["WEBFRONT_PENALTY_TEMPLATE_NAME"]</th>
<td>
@Html.ActionLink(Model.OffenderName, "ProfileAsync", "Client", new { id = Model.OffenderId }, new { @class = "link-inverse" })
</td>
</tr>
<tr class="d-table-row d-md-none bg-dark">
<th scope="row" class="bg-primary">Type</th>
<th scope="row" class="bg-primary">@loc["WEBFRONT_PENALTY_TEMPLATE_TYPE"]</th>
<td class="penalties-color-@Model.Type.ToLower()">
@Model.Type
</td>
</tr>
<tr class="d-table-row d-md-none bg-dark">
<th scope="row" class="bg-primary">Offense</th>
<th scope="row" class="bg-primary">@loc["WEBFRONT_PENALTY_TEMPLATE_OFFENSE"]</th>
<td class="text-light">
@Model.Offense
</td>
</tr>
<tr class="d-table-row d-md-none bg-dark">
<th scope="row" class="bg-primary">Admin</th>
<th scope="row" class="bg-primary">@loc["WEBFRONT_PENALTY_TEMPLATE_ADMIN"]</th>
<td>
@Html.ActionLink(Model.PunisherName, "ProfileAsync", "Client", new { id = Model.PunisherId }, new { @class = "level-color-" + Model.PunisherLevel.ToLower() })
</td>
</tr>
<tr class="d-table-row d-md-none bg-dark">
<th scope="row" class="w-25 bg-primary" style="border-bottom: 1px solid #222">Time/Left</th>
<th scope="row" class="w-25 bg-primary" style="border-bottom: 1px solid #222">@loc["WEBFRONT_PENALTY_TEMPLATE_TIME"]</th>
<td class="text-light mb-2 border-bottom">
@{
if (Model.TimeRemaining == string.Empty)
{
<span>@Model.TimePunished ago</span>
<span>@Model.TimePunished @loc["WEBFRONT_PENALTY_TEMPLATE_AGO"]</span>
}
else
{
<span> @Model.TimeRemaining left</span>
<span> @Model.TimeRemaining @loc["WEBFRONT_PENALTY_TEMPLATE_REMAINING"]</span>
}
}
</td>
@ -65,11 +66,11 @@
@{
if (Model.TimeRemaining == string.Empty)
{
<span>@Model.TimePunished ago</span>
<span>@Model.TimePunished @loc["WEBFRONT_PENALTY_TEMPLATE_AGO"]</span>
}
else
{
<span> @Model.TimeRemaining left</span>
<span> @Model.TimeRemaining @loc["WEBFRONT_PENALTY_TEMPLATE_REMAINING"]</span>
}
}
</td>

View File

@ -2,5 +2,5 @@
ViewData["Title"] = "Error";
}
<h4 class="text-danger">Sorry!</h4>
<h4 class="text-danger">An error occurred while processing your request.</h4>
<h4 class="text-danger">@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_GENERIC_TITLE"]</h4>
<h4 class="text-danger">@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_GENERIC_DESC"]</h4>

View File

@ -1,4 +1,7 @@
<!DOCTYPE html>
@{
var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
@ -32,13 +35,13 @@
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item text-center text-md-left">@Html.ActionLink("Home", "Index", "Home", new { area = "" }, new { @class = "nav-link" })</li>
<li class="nav-item text-center text-md-left">@Html.ActionLink("Penalties", "List", "Penalty", new { area = "" }, new { @class = "nav-link" })</li>
<li class="nav-item text-center text-md-left">@Html.ActionLink("Admins", "PrivilegedAsync", "Client", new { area = "" }, new { @class = "nav-link" })</li>
<li class="nav-item text-center text-md-left">@Html.ActionLink(loc["WEBFRONT_NAV_HOME"], "Index", "Home", new { area = "" }, new { @class = "nav-link" })</li>
<li class="nav-item text-center text-md-left">@Html.ActionLink(loc["WEBFRONT_NAV_PENALTIES"], "List", "Penalty", new { area = "" }, new { @class = "nav-link" })</li>
<li class="nav-item text-center text-md-left">@Html.ActionLink(loc["WEBFRONT_NAV_PRIVILEGED"], "PrivilegedAsync", "Client", new { area = "" }, new { @class = "nav-link" })</li>
<li class="nav-item text-center text-md-left"></li>
@if (!string.IsNullOrEmpty(ViewBag.DiscordLink))
@if (!string.IsNullOrEmpty(ViewBag.SocialLink))
{
<li class="nav-item text-center text-md-left"><a href="@ViewBag.DiscordLink" class="nav-link" target="_blank">Discord</a></li>
<li class="nav-item text-center text-md-left"><a href="@ViewBag.SocialLink" class="nav-link" target="_blank">@ViewBag.SocialTitle</a></li>
}
@if (ViewBag.Authorized)
{
@ -46,17 +49,17 @@
<a href="#" class="nav-link oi oi-person dropdown-toggle oi-fix-navbar w-100" id="account_dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></a>
<div class="dropdown-menu p-0" aria-labelledby="account_dropdown">
@Html.ActionLink("Console", "Index", "Console", new { area = "" }, new
@Html.ActionLink(loc["WEBFRONT_NAV_CONSOLE"], "Index", "Console", new { area = "" }, new
{
@class = "dropdown-item bg-dark text-muted text-center text-md-left",
title = "Web Console"
})
@Html.ActionLink("Profile", "ProfileAsync", "Client", new { id = ViewBag.User.ClientId }, new
@Html.ActionLink(loc["WEBFRONT_NAV_PROFILE"], "ProfileAsync", "Client", new { id = ViewBag.User.ClientId }, new
{
@class = "dropdown-item bg-dark text-muted text-center text-md-left",
title = "Client Profile",
})
@Html.ActionLink("Logout", "LogoutAsync", "Account", new { area = "" }, new
@Html.ActionLink(loc["WEBFRONT_NAV_LOGOUT"], "LogoutAsync", "Account", new { area = "" }, new
{
@class = "dropdown-item bg-dark text-muted text-center text-md-left",
title = "Logout of account"
@ -74,7 +77,7 @@
}
</ul>
<form class="form-inline text-primary pt-3 pb-3" method="get" action="/Client/FindAsync">
<input id="client_search" name="clientName" class="form-control mr-auto ml-auto mr-md-2" type="text" placeholder="Find Player" />
<input id="client_search" name="clientName" class="form-control mr-auto ml-auto mr-md-2" type="text" placeholder="@loc["WEBFRONT_NAV_SEARCH"]" />
</form>
</div>
</nav>