Use app.net Core to build a multi-language website, app. netcore
Asp.net Core has very few Chinese documents. You can read English documents, but English is also a bit messy. This article is dry. 1. configure your WebApplication so that it can support international languages and modify the document Startup. cs publicvoid ConfigureServices (IServiceCollection services) {services. addLocalization (options => options. resourcesPath = "Resources"); services. addMvc (). addViewLocalization (LanguageViewLocationExpanderFormat. suffix ). addDataAnnotationsLocalization ();} 2. modify your configuration public void Configure (IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory lo GgerFactory) {... the language that your website needs to support. Var supportedCultures = new [] {new CultureInfo ("en-US"), new CultureInfo ("zh-CN")}; here is the app that writes your default language. useRequestLocalization (new RequestLocalizationOptions {DefaultRequestCulture = new RequestCulture ("en-US"), // Formatting numbers, dates, etc. supportedCultures = supportedCultures, // UI strings that we have localized. supportedUICultures = supportedCultures});} 3. add resource document a to your view. add the Resources Directory B. press Your view path provides the structure of the resource document, for example, your view Views \ Home \ Index. cshtml your Resources \ Views \ Home \ Index. zh-CN.resx or Resources \ Views \ Home \ Index. en-US.resxc. add Key and Value d to the resource file. @ using Microsoft. aspNetCore. mvc. localization @ inject IViewLocalizer Localizer modify Learn More @ Localizer ["Learn More"] in the string to be displayed.