How To Implement Culture

Here is how to implement a specific culture in your application. In the Startup.cs, add following code to the ConfigureServices method:
public void ConfigureServices(IServiceCollection services) { services.Configure (options => { options.DefaultRequestCulture = new RequestCulture("da-DK"); }); services.AddControllersWithViews(); }
Let's say you add Asu (Tanzania) culture to the DefaultRequestCulture above and you carry out with following controllermethod and view: Controller
public IActionResult Index() { ViewBag.Today = DateTime.Now; ViewBag.MyWage = 10000.75; ViewBag.Culture = CultureInfo.CurrentCulture.DisplayName; ViewBag.UICulture = CultureInfo.CurrentUICulture.DisplayName; return View(); }
View
@{ ViewData["Title"] = "Home Page"; } <div> <div>@ViewBag.Today</div> <div>@ViewBag.MyWage</div> <div>Current culture : @ViewBag.Culture</div> <div>Current UI culture : @ViewBag.UICulture</div> </div>
You will have something like this:
The word Kipare (Tadhania) is not because there is a spell-error, that's how people from Tanzania write it.