Browse Source

Use new localization style in the templates.

pull/400/head 0.4.1.1
Halil ibrahim Kalkan 8 years ago
parent
commit
b2ce58259f
  1. 25
      templates/module/app/MyCompanyName.MyProjectName.DemoApp/DemoAppModule.cs
  2. 20
      templates/mvc/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs

25
templates/module/app/MyCompanyName.MyProjectName.DemoApp/DemoAppModule.cs

@ -1,13 +1,9 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.IO;
using System.Linq;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Localization;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using MyCompanyName.MyProjectName.EntityFrameworkCore;
using Swashbuckle.AspNetCore.Swagger;
using Volo.Abp;
@ -22,6 +18,7 @@ using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.Identity;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.Identity.Web;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
@ -81,17 +78,10 @@ namespace MyCompanyName.MyProjectName.DemoApp
options.DocInclusionPredicate((docName, description) => true);
});
var cultures = new List<CultureInfo>
context.Services.Configure<AbpLocalizationOptions>(options =>
{
new CultureInfo("en")
//Add other languages...
};
context.Services.Configure<RequestLocalizationOptions>(options =>
{
options.DefaultRequestCulture = new RequestCulture("en");
options.SupportedCultures = cultures;
options.SupportedUICultures = cultures;
options.Languages.Add(new LanguageInfo("en", "en", "English"));
//...add other languages
});
context.Services.AddAssemblyOf<DemoAppModule>();
@ -110,7 +100,6 @@ namespace MyCompanyName.MyProjectName.DemoApp
app.UseErrorPage();
}
app.UseStaticFiles();
app.UseVirtualFiles();
app.UseSwagger();
@ -120,9 +109,7 @@ namespace MyCompanyName.MyProjectName.DemoApp
});
app.UseAuthentication();
app.UseRequestLocalization(app.ApplicationServices.GetRequiredService<IOptions<RequestLocalizationOptions>>().Value);
app.UseAbpRequestLocalization();
app.UseAuditing();
app.UseMvc(routes =>

20
templates/mvc/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs

@ -1,13 +1,9 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.IO;
using Localization.Resources.AbpUi;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Localization;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using MyCompanyName.MyProjectName.EntityFrameworkCore;
using MyCompanyName.MyProjectName.Localization.MyProjectName;
using MyCompanyName.MyProjectName.Menus;
@ -122,14 +118,6 @@ namespace MyCompanyName.MyProjectName
private static void ConfigureLocalizationServices(IServiceCollection services)
{
var cultures = new List<CultureInfo> {new CultureInfo("en"), new CultureInfo("tr")};
services.Configure<RequestLocalizationOptions>(options =>
{
options.DefaultRequestCulture = new RequestCulture("en");
options.SupportedCultures = cultures;
options.SupportedUICultures = cultures;
});
services.Configure<AbpLocalizationOptions>(options =>
{
options.Resources
@ -138,6 +126,9 @@ namespace MyCompanyName.MyProjectName
typeof(AbpValidationResource),
typeof(AbpUiResource)
);
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
});
}
@ -183,8 +174,7 @@ namespace MyCompanyName.MyProjectName
app.UseVirtualFiles();
app.UseAuthentication();
app.UseRequestLocalization(app.ApplicationServices.GetRequiredService<IOptions<RequestLocalizationOptions>>().Value);
app.UseAbpRequestLocalization();
app.UseSwagger();
app.UseSwaggerUI(options =>

Loading…
Cancel
Save