访问MVC Core _ Layout.cshtml中的所选请求本地化区域性



使用标准.net本地化中间件:

var supportedCultures = new List<CultureInfo> { new CultureInfo("en"), new CultureInfo("de") ...
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en", "en"),
SupportedCultures = supportedCultures, ...

如何访问所选语言,以便在_Layout.cshtml中添加以下内容:

<html lang="@[????].CultureCode">

它看起来仍然与旧的ASP.NET 4.x days:完全相同的命名空间和属性

<html lang="@System.Threading.Thread.CurrentThread.CurrentUICulture.Name">

最新更新