使用标准.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">