问题
In my MVC application I have had the following line and it has worked fine.
if (Thread.CurrentThread.CurrentUICulture.Name == localizationItem.CultureInfo.Trim())
Now as I am porting my application over to .Net Core 1.1, it appears that CurrentUICulture has went missing in action. Any ideas on what it's replacement is?
Severity Code Description Project File Line Suppression State Error CS1061 'Thread' does not contain a definition for 'CurrentUICulture' and no extension method 'CurrentUICulture' accepting a first argument of type 'Thread' could be found (are you missing a using directive or an assembly reference?) framework..NETCoreApp,Version=v1.1
回答1:
I believe you're looking to do localization.
Have a look here on how you can do it
Once it's setup, you can use something like this to get the current culture for a user:
var rqf = Request.HttpContext.Features.Get<IRequestCultureFeature>();
var culture = rqf.RequestCulture.Culture;
来源:https://stackoverflow.com/questions/42540599/thread-currentthread-currentuiculture-in-asp-net-core