The ASP. NET Core Chinese documents are very few, you can look at English, but the English is also a bit messy. This article is dry. 1. Configure your webapplication so that he can support the internationalization language, 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 loggerfactory){...This contains the languages that your website needs to support. var supportedcultures = New[] { New CultureInfo("en -us"), New CultureInfo("ZH-CN") };This is the default language you write .app. Userequestlocalization (New requestlocalizationoptions {defaultrequestculture = New requestculture("en -us"), //formatting numbers, dates, etc.supportedcultures = supportedcultures, //UI strings that we have localized.supporteduicultures = SupportedCultures });3. Add resources to your view document A. Add Resources directory B. According to your view path, give the structure of the resource document such as your view views\home\index.cshtml your resources resources\views\home\ Index.zh-cn.resx or RESOURCES\VIEWS\HOME\INDEX.EN-US.RESXC. Add key and Value D to the resource file. Top of view@using Microsoft.AspNetCore.Mvc.Localization@inject Iviewlocalizer Localizerthe string that needs to be displayedwill beLearn moreModify@Localizer ["Learn More"]Test RunGet some.
Use App.net core to make multi-lingual websites.