1616using RulesEngineEditor . Services ;
1717using RulesEngineEditor . Data ;
1818using Microsoft . EntityFrameworkCore ;
19+ using Microsoft . AspNetCore . Localization ;
20+ using System . Globalization ;
1921
2022namespace RulesEngineEditorServer
2123{
@@ -34,6 +36,7 @@ public void ConfigureServices(IServiceCollection services)
3436 {
3537 services . AddRazorPages ( ) ;
3638 services . AddServerSideBlazor ( ) ;
39+ services . AddLocalization ( options => options . ResourcesPath = "Resources" ) ;
3740 services . AddSingleton < WeatherForecastService > ( ) ;
3841
3942 //services.AddDbContext<RulesEngineEditorDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("RulesEngineEditorDB")));
@@ -45,6 +48,14 @@ public void ConfigureServices(IServiceCollection services)
4548 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
4649 public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
4750 {
51+ var supportedCultures = new [ ] { new CultureInfo ( "en-US" ) , new CultureInfo ( "zh-CN" ) } ;
52+ var localizationOptions = new RequestLocalizationOptions
53+ {
54+ DefaultRequestCulture = new RequestCulture ( "en-US" ) ,
55+ SupportedCultures = supportedCultures ,
56+ SupportedUICultures = supportedCultures
57+ } ;
58+ app . UseRequestLocalization ( localizationOptions ) ;
4859 if ( env . IsDevelopment ( ) )
4960 {
5061 app . UseDeveloperExceptionPage ( ) ;
0 commit comments