diff --git a/Bootstrap.Admin/Resources/Views/Account/Login.zh-CN.resx b/Bootstrap.Admin/Resources/Views/Account/Login.zh-CN.resx new file mode 100644 index 00000000..39413f69 --- /dev/null +++ b/Bootstrap.Admin/Resources/Views/Account/Login.zh-CN.resx @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 忘记密码 + + + 用户名或密码错误! + + + 登 陆 + + + 密码 + + + 请输入密码 + + + 请输入用户名 + + + 记住密码自动登录 + + + 申请账号 + + + 用户名 + + \ No newline at end of file diff --git a/Bootstrap.Admin/Resources/Views/Home/Index.zh-CN.resx b/Bootstrap.Admin/Resources/Views/Home/Index.zh-CN.resx new file mode 100644 index 00000000..859c5f6f --- /dev/null +++ b/Bootstrap.Admin/Resources/Views/Home/Index.zh-CN.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 首页 + + \ No newline at end of file diff --git a/Bootstrap.Admin/Startup.cs b/Bootstrap.Admin/Startup.cs index d9438495..5a2f0275 100644 --- a/Bootstrap.Admin/Startup.cs +++ b/Bootstrap.Admin/Startup.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.AspNetCore.Mvc.Versioning; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -17,6 +18,8 @@ using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using Swashbuckle.AspNetCore.Swagger; using System; +using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Text.Encodings.Web; using System.Text.Unicode; @@ -50,6 +53,7 @@ namespace Bootstrap.Admin public void ConfigureServices(IServiceCollection services) { services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All)); + services.AddLocalization(op => op.ResourcesPath = "Resources"); services.Configure(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. @@ -80,7 +84,7 @@ namespace Bootstrap.Admin options.SerializerSettings.ContractResolver = new DefaultContractResolver(); options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; JsonConvert.DefaultSettings = () => options.SerializerSettings; - }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + }).AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix).SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => { options.Cookie.Path = "/"; @@ -118,6 +122,7 @@ namespace Bootstrap.Admin public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseForwardedHeaders(new ForwardedHeadersOptions() { ForwardedHeaders = ForwardedHeaders.All }); + app.UseRequestLocalization(options => options.AddSupportedCultures("en-us", "zh-CN").AddSupportedUICultures("en-us", "zh-CN")); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); @@ -158,4 +163,4 @@ namespace Bootstrap.Admin }); } } -} \ No newline at end of file +} diff --git a/Bootstrap.Admin/Views/Account/Login.cshtml b/Bootstrap.Admin/Views/Account/Login.cshtml index 4b5fd5d3..53146e64 100644 --- a/Bootstrap.Admin/Views/Account/Login.cshtml +++ b/Bootstrap.Admin/Views/Account/Login.cshtml @@ -1,4 +1,5 @@ @model LoginModel +@inject IViewLocalizer Localizer @{ ViewBag.Title = Model.Title; Layout = "_Layout"; @@ -46,7 +47,7 @@
@@ -64,18 +65,18 @@
- +
- 记住密码自动登录 + @Localizer["Remember me"]
- +
diff --git a/Bootstrap.Admin/Views/Home/Index.cshtml b/Bootstrap.Admin/Views/Home/Index.cshtml index 8f66e810..a8c630a6 100644 --- a/Bootstrap.Admin/Views/Home/Index.cshtml +++ b/Bootstrap.Admin/Views/Home/Index.cshtml @@ -1,9 +1,11 @@ -@{ - ViewBag.Title = "首页"; +@inject IViewLocalizer Localizer +@{ + ViewBag.Title = @Localizer["Home"]; Layout = "_Bootstrap"; } @section css {