feat StayExport - Added LocalizerService

- Added new "LocalizerService" to get localization for enum values (and other dynamic/db values in the future).
This commit is contained in:
2026-09-02 13:15:10 +02:00
parent b318f2415c
commit cf31cbc414
6 changed files with 56 additions and 20 deletions
@@ -1,26 +1,15 @@
using Microsoft.Extensions.Localization;
using MudBlazor;
using Somnia.GuestLog.Enums.Services;
using Somnia.GuestLog.Enums.UI;
using Somnia.GuestLog.Models.DTOs;
using Somnia.GuestLog.Resources;
namespace Somnia.GuestLog.Services;
public class UserMessageService(
IServiceProvider serviceProvider,
ILocalizerService Localizer,
ISnackbar snackbar
) : IUserMessageService
{
private IStringLocalizer<LanguageLocale> _localizer
{
get
{
return serviceProvider.GetRequiredService<IStringLocalizer<LanguageLocale>>();
}
}
public void ShowMessage(string text, MessageKind kind, params object[] parameters)
{
string formatedMsg = GetFormatedMessage(text, parameters);
@@ -61,7 +50,7 @@ public class UserMessageService(
private string GetMsgForResultCode(ResultCode resultCode)
{
return _localizer[$"resultCode.{Enum.GetName(resultCode)}"];
return Localizer.GetEnumValue(resultCode);
}
private static string GetFormatedMessage(string template, params object[]? parameters)