diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2026-05-04 20:26:39 +0200 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2026-05-12 23:18:38 +0200 |
| commit | 4be3f5f1f9ff8bd0333033d6ad9c99711da03f96 (patch) | |
| tree | b4ab723756891c153d1b67d49ffa45f579335b91 /Emby.Server.Implementations/HttpServer/WebSocketManager.cs | |
| parent | e9942c385775f33c70dbb4b910085ae2c563e898 (diff) | |
Add Accept-Language header support for per-request localization
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/WebSocketManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/HttpServer/WebSocketManager.cs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/HttpServer/WebSocketManager.cs b/Emby.Server.Implementations/HttpServer/WebSocketManager.cs index cb5b3993b8..3b5f6d1d09 100644 --- a/Emby.Server.Implementations/HttpServer/WebSocketManager.cs +++ b/Emby.Server.Implementations/HttpServer/WebSocketManager.cs @@ -4,9 +4,11 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Net.WebSockets; using System.Threading.Tasks; +using Emby.Server.Implementations.Localization; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Net; using Microsoft.AspNetCore.Http; @@ -48,13 +50,22 @@ namespace Emby.Server.Implementations.HttpServer WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync().ConfigureAwait(false); + // Capture the culture context set by AcceptLanguageMiddleware so it can be + // restored both when processing incoming messages and when periodic + // listeners produce server-initiated payloads on background tasks. var connection = new WebSocketConnection( _loggerFactory.CreateLogger<WebSocketConnection>(), webSocket, authorizationInfo, context.GetNormalizedRemoteIP()) { - OnReceive = ProcessWebSocketMessageReceived + RequestCultureFallback = LocalizationManager.RequestCultureFallback, + RequestUICulture = CultureInfo.CurrentUICulture.Name + }; + connection.OnReceive = result => + { + connection.ApplyRequestCulture(); + return ProcessWebSocketMessageReceived(result); }; await using (connection.ConfigureAwait(false)) { |
