SHA256
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user