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,12 +1,20 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using PlanTempus.Application.Features.Localization.Services;
|
||||
|
||||
namespace PlanTempus.Application.Features.Dashboard.Components;
|
||||
|
||||
public class QuickStatListViewComponent : ViewComponent
|
||||
{
|
||||
private readonly ILocalizationService _localization;
|
||||
|
||||
public QuickStatListViewComponent(ILocalizationService localization)
|
||||
{
|
||||
_localization = localization;
|
||||
}
|
||||
|
||||
public IViewComponentResult Invoke(string key)
|
||||
{
|
||||
var model = QuickStatListCatalog.Get(key);
|
||||
var model = QuickStatListCatalog.Get(key, _localization);
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
|
@ -19,24 +27,38 @@ public class QuickStatListViewModel
|
|||
public required IReadOnlyList<string> StatKeys { get; init; }
|
||||
}
|
||||
|
||||
internal class QuickStatListData
|
||||
{
|
||||
public required string Key { get; init; }
|
||||
public required string TitleKey { get; init; }
|
||||
public required string Icon { get; init; }
|
||||
public required IReadOnlyList<string> StatKeys { get; init; }
|
||||
}
|
||||
|
||||
public static class QuickStatListCatalog
|
||||
{
|
||||
private static readonly Dictionary<string, QuickStatListViewModel> Lists = new()
|
||||
private static readonly Dictionary<string, QuickStatListData> Lists = new()
|
||||
{
|
||||
["this-week"] = new QuickStatListViewModel
|
||||
["this-week"] = new QuickStatListData
|
||||
{
|
||||
Key = "this-week",
|
||||
Title = "Denne uge",
|
||||
TitleKey = "dashboard.quickStats.title",
|
||||
Icon = "chart-line-up",
|
||||
StatKeys = ["bookings-week", "revenue-week", "new-customers", "avg-occupancy"]
|
||||
}
|
||||
};
|
||||
|
||||
public static QuickStatListViewModel Get(string key)
|
||||
public static QuickStatListViewModel Get(string key, ILocalizationService localization)
|
||||
{
|
||||
if (Lists.TryGetValue(key, out var list))
|
||||
return list;
|
||||
if (!Lists.TryGetValue(key, out var list))
|
||||
throw new KeyNotFoundException($"QuickStatList with key '{key}' not found");
|
||||
|
||||
throw new KeyNotFoundException($"QuickStatList with key '{key}' not found");
|
||||
return new QuickStatListViewModel
|
||||
{
|
||||
Key = list.Key,
|
||||
Title = localization.Get(list.TitleKey),
|
||||
Icon = list.Icon,
|
||||
StatKeys = list.StatKeys
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue