Set context language

The best way is to add a new middleware to set the Context language.

public class SetDefaultLanguage
{
    private readonly RequestDelegate _next;
    private IHttpContextAccessor _httpContextAccessor;

    public SetDefaultLanguage(RequestDelegate next, IHttpContextAccessor httpContextAccessor)
    {
        _next = next;
        _httpContextAccessor = httpContextAccessor;
    }
    
    public async Task Invoke(HttpContext context)
    {
        if (context.Request.Headers.TryGetValue("language", out var language))
        {
            _httpContextAccessor.HttpContext.Items["language"] = language.ToString();
            
            await _next(context);
            return;
        }
        
        _httpContextAccessor.HttpContext.Items["language"] = "en";
        
        await _next(context);
        return;
    }
}

// add to services

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{        
    ...       
    app.UseMiddleware<SetDefaultLanguage>();
    ...
}