locked
.Net Core Localization RRS feed

  • Question

  • Hi,

    In my .NET Core Controller, I'd like to set localization to the value preferred by the client's browser. So, for example, if my #1 language/Culture preference is en-CA (English Canada), I'd like my web server to automatically reflect that.

    In prior versions of .Net, this was accomplished via something like the following:

    System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);

    How is that handled in .Net Core?

    We are using VS 2017, Windows 10, .Net Core 1.04. 

    Thursday, August 10, 2017 9:13 PM

Answers

All replies

  • Hi DaveIII,

    Welcome to MSDN forum.

    Please have a look at the docs: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization

    If you have questions about .Net Core, I recommend you go to ASP.NET core forum.

    Best regards,

    Joyce


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 11, 2017 7:21 AM
  • public void ConfigureServices(IServiceCollection services)
            {
                var cultureInfo = new CultureInfo("pt-BR");
                CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
                CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
    Wednesday, October 30, 2019 5:27 AM