Skip to content

Commit 80c76ed

Browse files
committed
Fix browser language detection. #631
1 parent 1c3f709 commit 80c76ed

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System;
5-
using System.Linq;
5+
using System.Globalization;
66
using System.Net;
77
using System.Threading.Tasks;
88
using DotNetCore.CAP.Dashboard;
99
using DotNetCore.CAP.Dashboard.GatewayProxy;
1010
using DotNetCore.CAP.Dashboard.NodeDiscovery;
11+
using DotNetCore.CAP.Dashboard.Resources;
1112
using DotNetCore.CAP.Persistence;
1213
using Microsoft.AspNetCore.Builder;
1314
using Microsoft.AspNetCore.Hosting;
@@ -36,7 +37,6 @@ public static IApplicationBuilder UseCapDashboard(this IApplicationBuilder app)
3637
{
3738
app.UseMiddleware<GatewayProxyMiddleware>();
3839
}
39-
4040
app.UseMiddleware<DashboardMiddleware>();
4141
}
4242

@@ -77,7 +77,7 @@ public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
7777
app.UseCapDashboard();
7878

7979
next(app);
80-
};
80+
};
8181
}
8282
}
8383

@@ -106,6 +106,9 @@ public async Task Invoke(HttpContext context)
106106
return;
107107
}
108108

109+
var userLanguages = context.Request.Headers["Accept-Language"].ToString();
110+
Strings.Culture = userLanguages.Contains("zh-") ? new CultureInfo("zh-CN") : new CultureInfo("en-US");
111+
109112
// Update the path
110113
var path = context.Request.Path;
111114
var pathBase = context.Request.PathBase;

0 commit comments

Comments
 (0)