diff --git a/docs/Index.md b/docs/Index.md index 3f4f6a85cf..19aaf0dafd 100644 --- a/docs/Index.md +++ b/docs/Index.md @@ -6,4 +6,6 @@ * Getting Started * With Console Application - * With ASP.NET Core Web Application \ No newline at end of file + * With ASP.NET Core Web Application +* Presentation (User Interface) + * Localization \ No newline at end of file diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs index aa790692fb..13adf1437f 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs +++ b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Globalization; using AbpDesk.EntityFrameworkCore; using AbpDesk.Web.Mvc.Navigation; using AbpDesk.Web.Mvc.Temp; @@ -8,6 +10,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Localization; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Volo.Abp; @@ -87,6 +90,21 @@ namespace AbpDesk.Web.Mvc app.UseAuthentication(); + var cultures = new List + { + new CultureInfo("en"), + new CultureInfo("tr") + }; + + //TODO: Should we add this to the framework, or left it to the application? + //TODO: Should we add this as the first middleware (to support localization in all middlewares too)? + app.UseRequestLocalization(new RequestLocalizationOptions + { + DefaultRequestCulture = new RequestCulture("en"), + SupportedCultures = cultures, + SupportedUICultures = cultures + }); + app.UseMvc(routes => { routes.MapRoute( diff --git a/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs b/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs index 661127fdd8..ddc7a29b57 100644 --- a/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs +++ b/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs @@ -2,7 +2,9 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; using Volo.Abp.EmbeddedFiles; +using Volo.Abp.Identity.Web.Areas.Identity.Localization.Resource; using Volo.Abp.Identity.Web.Navigation; +using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.Ui.Navigation; @@ -39,6 +41,11 @@ namespace Volo.Abp.Identity.Web ) ); }); + + services.Configure(options => + { + options.Resources.AddJson("en"); + }); } } } diff --git a/src/Volo.Abp.Identity.Web/Areas/Identity/Localization/Resource/IdentityResource.cs b/src/Volo.Abp.Identity.Web/Areas/Identity/Localization/Resource/IdentityResource.cs new file mode 100644 index 0000000000..69b81c54f1 --- /dev/null +++ b/src/Volo.Abp.Identity.Web/Areas/Identity/Localization/Resource/IdentityResource.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.Identity.Web.Areas.Identity.Localization.Resource +{ + public class IdentityResource + { + + } +} diff --git a/src/Volo.Abp.Identity.Web/Areas/Identity/Localization/Resource/en.json b/src/Volo.Abp.Identity.Web/Areas/Identity/Localization/Resource/en.json new file mode 100644 index 0000000000..647d3d4e1b --- /dev/null +++ b/src/Volo.Abp.Identity.Web/Areas/Identity/Localization/Resource/en.json @@ -0,0 +1,6 @@ +{ + "culture": "en", + "texts": { + "Users": "Users" + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Identity.Web/Areas/Identity/Localization/Resource/tr.json b/src/Volo.Abp.Identity.Web/Areas/Identity/Localization/Resource/tr.json new file mode 100644 index 0000000000..31b5bd18fa --- /dev/null +++ b/src/Volo.Abp.Identity.Web/Areas/Identity/Localization/Resource/tr.json @@ -0,0 +1,6 @@ +{ + "culture": "tr", + "texts": { + "Users": "Kullanıcılar" + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Identity.Web/Areas/Identity/Views/Users/Index.cshtml b/src/Volo.Abp.Identity.Web/Areas/Identity/Views/Users/Index.cshtml index 1ca863d12e..a8de93047d 100644 --- a/src/Volo.Abp.Identity.Web/Areas/Identity/Views/Users/Index.cshtml +++ b/src/Volo.Abp.Identity.Web/Areas/Identity/Views/Users/Index.cshtml @@ -1,4 +1,7 @@ -@section styles { +@using Microsoft.Extensions.Localization +@using Volo.Abp.Identity.Web.Areas.Identity.Localization.Resource +@inject IStringLocalizer Localizer +@section styles { @@ -12,7 +15,7 @@
-

Users

+

@Localizer["Users"]

diff --git a/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj b/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj index 8351793d79..77797d9147 100644 --- a/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj +++ b/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj @@ -10,17 +10,11 @@ - - - - - - - - - - - + + + + +