Hello Guys,
I am building MultiLanguage Application in Asp.net core but I am not able to change the text to another format.here is my code please let me know what wrong.
statup.cs public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.Add(new ServiceDescriptor(typeof(NcsdbContext), new NcsdbContext(Configuration.GetConnectionString("DefaultConnection")))); services.AddDbContext<TestAppContext>(options => options.UseMySQL(Configuration.GetConnectionString("DefaultConnection"))); services.AddApplicationInsightsTelemetry(Configuration); services.AddLocalization(options => options.ResourcesPath = "Resources"); services.Configure<RequestLocalizationOptions>(options => { var supportedCultures = new[] { new CultureInfo("en-US"), new CultureInfo("hi-IN"), new CultureInfo("mr-IN") }; options.DefaultRequestCulture = new RequestCulture(culture: "en-US", uiCulture: "en-US"); options.SupportedCultures = supportedCultures; options.SupportedUICultures = supportedCultures; }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { var localizationOption = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>(); app.UseRequestLocalization(localizationOption.Value); if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); });
ResourceFiles Controllers.HomeController.en-US.resx Controllers.HomeController.hi-IN.resx
Home Controller public class HomeController : Controller { private readonly IStringLocalizer<HomeController> _localizer; public HomeController(IStringLocalizer<HomeController> localizer) { _localizer = localizer; } public IActionResult Index() { return View(); }