refactor(HomeController): remove culture binding as viewdata; bind via string localizer
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using EnvelopeGenerator.Web.Models;
|
||||
using EnvelopeGenerator.Web.Controllers;
|
||||
using EnvelopeGenerator.Web.Models;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Globalization;
|
||||
@@ -23,20 +24,7 @@ public class CultureMiddleware
|
||||
|
||||
if (string.IsNullOrEmpty(cookieValue))
|
||||
{
|
||||
var culture = new RequestCulture(_cultures.Default.Language);
|
||||
|
||||
var cookieOptions = new CookieOptions
|
||||
{
|
||||
Secure = false,
|
||||
SameSite = SameSiteMode.Strict,
|
||||
HttpOnly = true
|
||||
};
|
||||
|
||||
context.Response.Cookies.Append(
|
||||
cookieName,
|
||||
CookieRequestCultureProvider.MakeCookieValue(culture),
|
||||
cookieOptions);
|
||||
|
||||
context.Response.Cookies.SetCulture(_cultures.Default.Language);
|
||||
CultureInfo.CurrentCulture = new CultureInfo(_cultures.Default.Language);
|
||||
CultureInfo.CurrentUICulture = new CultureInfo(_cultures.Default.Language);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user