Adds localization support across application views
Implements localization for dashboard, cash register, account, and profile sections Adds localization keys for various UI elements, improving internationalization support Refactors view components to use ILocalizationService for dynamic text rendering Prepares ground for multi-language support with translation-ready markup
This commit is contained in:
parent
1f400dcc6e
commit
ef174af0e1
36 changed files with 821 additions and 263 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using PlanTempus.Application.Features.Localization.Services;
|
||||
|
||||
namespace PlanTempus.Application.Features.Dashboard.Components;
|
||||
|
||||
|
|
@ -7,9 +8,16 @@ namespace PlanTempus.Application.Features.Dashboard.Components;
|
|||
/// </summary>
|
||||
public class QuickStatViewComponent : ViewComponent
|
||||
{
|
||||
private readonly ILocalizationService _localization;
|
||||
|
||||
public QuickStatViewComponent(ILocalizationService localization)
|
||||
{
|
||||
_localization = localization;
|
||||
}
|
||||
|
||||
public IViewComponentResult Invoke(string key)
|
||||
{
|
||||
var model = QuickStatCatalog.Get(key);
|
||||
var model = QuickStatCatalog.Get(key, _localization);
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
|
@ -24,45 +32,57 @@ public class QuickStatViewModel
|
|||
public required string Label { get; init; }
|
||||
}
|
||||
|
||||
internal class QuickStatData
|
||||
{
|
||||
public required string Key { get; init; }
|
||||
public required string Value { get; init; }
|
||||
public required string LabelKey { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Catalog of available quick stats with their data.
|
||||
/// </summary>
|
||||
public static class QuickStatCatalog
|
||||
{
|
||||
private static readonly Dictionary<string, QuickStatViewModel> Stats = new()
|
||||
private static readonly Dictionary<string, QuickStatData> Stats = new()
|
||||
{
|
||||
["bookings-week"] = new QuickStatViewModel
|
||||
["bookings-week"] = new QuickStatData
|
||||
{
|
||||
Key = "bookings-week",
|
||||
Value = "47",
|
||||
Label = "Bookinger"
|
||||
LabelKey = "dashboard.quickStats.bookings"
|
||||
},
|
||||
["revenue-week"] = new QuickStatViewModel
|
||||
["revenue-week"] = new QuickStatData
|
||||
{
|
||||
Key = "revenue-week",
|
||||
Value = "38.200 kr",
|
||||
Label = "Omsætning"
|
||||
LabelKey = "dashboard.quickStats.revenue"
|
||||
},
|
||||
["new-customers"] = new QuickStatViewModel
|
||||
["new-customers"] = new QuickStatData
|
||||
{
|
||||
Key = "new-customers",
|
||||
Value = "8",
|
||||
Label = "Nye kunder"
|
||||
LabelKey = "dashboard.quickStats.newCustomers"
|
||||
},
|
||||
["avg-occupancy"] = new QuickStatViewModel
|
||||
["avg-occupancy"] = new QuickStatData
|
||||
{
|
||||
Key = "avg-occupancy",
|
||||
Value = "72%",
|
||||
Label = "Gns. belægning"
|
||||
LabelKey = "dashboard.quickStats.avgOccupancy"
|
||||
}
|
||||
};
|
||||
|
||||
public static QuickStatViewModel Get(string key)
|
||||
public static QuickStatViewModel Get(string key, ILocalizationService localization)
|
||||
{
|
||||
if (Stats.TryGetValue(key, out var stat))
|
||||
return stat;
|
||||
if (!Stats.TryGetValue(key, out var stat))
|
||||
throw new KeyNotFoundException($"QuickStat with key '{key}' not found");
|
||||
|
||||
throw new KeyNotFoundException($"QuickStat with key '{key}' not found");
|
||||
return new QuickStatViewModel
|
||||
{
|
||||
Key = stat.Key,
|
||||
Value = stat.Value,
|
||||
Label = localization.Get(stat.LabelKey)
|
||||
};
|
||||
}
|
||||
|
||||
public static IEnumerable<string> AllKeys => Stats.Keys;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue