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:
Janus C. H. Knudsen 2026-01-12 15:42:18 +01:00
parent 1f400dcc6e
commit ef174af0e1
36 changed files with 821 additions and 263 deletions

View file

@ -1,12 +1,20 @@
using Microsoft.AspNetCore.Mvc;
using PlanTempus.Application.Features.Localization.Services;
namespace PlanTempus.Application.Features.Dashboard.Components;
public class BookingListViewComponent : ViewComponent
{
private readonly ILocalizationService _localization;
public BookingListViewComponent(ILocalizationService localization)
{
_localization = localization;
}
public IViewComponentResult Invoke(string key)
{
var model = BookingListCatalog.Get(key);
var model = BookingListCatalog.Get(key, _localization);
return View(model);
}
}
@ -19,24 +27,38 @@ public class BookingListViewModel
public required IReadOnlyList<string> BookingKeys { get; init; }
}
internal class BookingListData
{
public required string Key { get; init; }
public required string TitleKey { get; init; }
public required string CurrentTime { get; init; }
public required IReadOnlyList<string> BookingKeys { get; init; }
}
public static class BookingListCatalog
{
private static readonly Dictionary<string, BookingListViewModel> Lists = new()
private static readonly Dictionary<string, BookingListData> Lists = new()
{
["todays-bookings"] = new BookingListViewModel
["todays-bookings"] = new BookingListData
{
Key = "todays-bookings",
Title = "Dagens bookinger",
TitleKey = "dashboard.bookings.title",
CurrentTime = "10:45",
BookingKeys = ["booking-1", "booking-2", "booking-3", "booking-4", "booking-5", "booking-6"]
}
};
public static BookingListViewModel Get(string key)
public static BookingListViewModel Get(string key, ILocalizationService localization)
{
if (Lists.TryGetValue(key, out var list))
return list;
if (!Lists.TryGetValue(key, out var list))
throw new KeyNotFoundException($"BookingList with key '{key}' not found");
throw new KeyNotFoundException($"BookingList with key '{key}' not found");
return new BookingListViewModel
{
Key = list.Key,
Title = localization.Get(list.TitleKey),
CurrentTime = list.CurrentTime,
BookingKeys = list.BookingKeys
};
}
}