# .Net Core切換語系 1.調整 Startup的 ConfigureServices,並且指定路徑為 "Resources" ``` services.AddLocalization(options => options.ResourcesPath = "Resources"); services.AddMvc() //.AddViewLocalization() .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix);//要使用View多國語系的話就加這行程式碼 ``` 2.在Configure中設定支援的語系列表 預設的文化及UI文化(一個是顯示的語言,一個是資料顯示的格式) ``` var supportedCultures = new List<CultureInfo>() { new CultureInfo("zh-TW"), new CultureInfo("en-US"), }; app.UseRequestLocalization(new RequestLocalizationOptions() { DefaultRequestCulture = new RequestCulture("zh-TW"), SupportedCultures = supportedCultures, SupportedUICultures = supportedCultures, }); ``` 3.在Resourcees資料夾建立資源檔(.resx),並位置相對應View ![](https://i.imgur.com/nksLabd.png) 4.建立資料 ![](https://i.imgur.com/0TmgvKF.png) 5.在View上面新增以下程式碼 ``` @using Microsoft.AspNetCore.Mvc.Localization @inject IViewLocalizer MyViewLocalizer ``` 6.將原本文字改成在資源檔所建立的名稱 ![](https://i.imgur.com/eSdJ2mU.png)