Improved localization

This commit is contained in:
Mia Rose Winter 2024-01-15 22:13:20 +01:00
parent 1af00d1e90
commit b0de0dd165
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E
2 changed files with 16 additions and 0 deletions

View file

@ -1,4 +1,5 @@
@using System.Globalization @using System.Globalization
@using Microsoft.AspNetCore.Localization
<!DOCTYPE html> <!DOCTYPE html>
<html lang="@CultureInfo.CurrentUICulture.ToString()"> <html lang="@CultureInfo.CurrentUICulture.ToString()">
@ -39,3 +40,17 @@
</body> </body>
</html> </html>
@code {
[CascadingParameter]
public HttpContext? HttpContext { get; set; }
protected override void OnInitialized() {
HttpContext?.Response.Cookies.Append(
CookieRequestCultureProvider.DefaultCookieName,
CookieRequestCultureProvider.MakeCookieValue(
new RequestCulture(
CultureInfo.CurrentCulture,
CultureInfo.CurrentUICulture)));
}
}

View file

@ -4,6 +4,7 @@
@using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web
@using Microsoft.Extensions.Localization
@using static Microsoft.AspNetCore.Components.Web.RenderMode @using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop @using Microsoft.JSInterop