Skip to content

Commit

Permalink
Use new localization style in the templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalkan committed Aug 4, 2018
1 parent d035ad1 commit b2ce582
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -22,6 +18,7 @@
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;
Expand Down Expand Up @@ -81,17 +78,10 @@ public override void ConfigureServices(ServiceConfigurationContext context)
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>();
Expand All @@ -110,7 +100,6 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
app.UseErrorPage();
}

app.UseStaticFiles();
app.UseVirtualFiles();

app.UseSwagger();
Expand All @@ -120,9 +109,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
});

app.UseAuthentication();

app.UseRequestLocalization(app.ApplicationServices.GetRequiredService<IOptions<RequestLocalizationOptions>>().Value);

app.UseAbpRequestLocalization();
app.UseAuditing();

app.UseMvc(routes =>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -122,14 +118,6 @@ private static void ConfigureVirtualFileSystem(IServiceCollection services, IHos

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
Expand All @@ -138,6 +126,9 @@ private static void ConfigureLocalizationServices(IServiceCollection services)
typeof(AbpValidationResource),
typeof(AbpUiResource)
);

options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
});
}

Expand Down Expand Up @@ -183,8 +174,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex

app.UseVirtualFiles();
app.UseAuthentication();

app.UseRequestLocalization(app.ApplicationServices.GetRequiredService<IOptions<RequestLocalizationOptions>>().Value);
app.UseAbpRequestLocalization();

app.UseSwagger();
app.UseSwaggerUI(options =>
Expand Down

0 comments on commit b2ce582

Please sign in to comment.