refactor(HomeController): remove culture binding as viewdata; bind via string localizer

This commit is contained in:
2025-08-23 00:14:43 +02:00
parent 0b33ba0fd8
commit d390802305
14 changed files with 190 additions and 153 deletions

View File

@@ -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);
}