classlib/ExpenseTracker.Api/Services/InternationalizationService.cs
2024-08-07 21:12:02 +03:00

19 lines
564 B
C#

using ExpenseTracker.Application.Common.Interfaces.Services;
using ExpenseTracker.Domain.Enums;
namespace ExpenseTracker.Api.Services;
public class InternationalizationService : IInternationalizationService
{
private readonly HttpContext _httpContext;
public InternationalizationService(IHttpContextAccessor httpContextAccessor)
{
_httpContext = httpContextAccessor.HttpContext!;
Currency = Currency.FromName(_httpContext.Request.Headers["Accept-Currency"]) ?? Currency.Default;
}
public Currency Currency { get; init; }
}