From d3a0b3581195d7e981a2aeb21c3aa52e8d853d05 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Mon, 25 Apr 2022 11:58:33 -0500 Subject: [PATCH] Added appropriate startup services and configs. Added example files for reference on how to perform localization. --- Props/Props.csproj | 1 - Props/Startup.cs | 18 ++++++++++++++++-- Props/locales/Pages/Index.en-US.resx | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 Props/locales/Pages/Index.en-US.resx diff --git a/Props/Props.csproj b/Props/Props.csproj index 50f2ae4..fe0d57e 100644 --- a/Props/Props.csproj +++ b/Props/Props.csproj @@ -5,7 +5,6 @@ net6.0 true - true false true diff --git a/Props/Startup.cs b/Props/Startup.cs index 36f1ef2..54c5978 100644 --- a/Props/Startup.cs +++ b/Props/Startup.cs @@ -7,7 +7,6 @@ using Microsoft.Extensions.Hosting; using Props.Data; using Props.Models.User; using Props.Services.Modules; -using System; namespace Props { @@ -44,7 +43,16 @@ namespace Props } services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores(); - services.AddRazorPages(); + + services.AddLocalization(options => + { + options.ResourcesPath = "locales"; + }); + + services.AddRazorPages().AddViewLocalization(options => + { + options.ResourcesPath = "locales"; + }).AddDataAnnotationsLocalization(); services.AddSingleton(); services.AddScoped(); @@ -61,8 +69,14 @@ namespace Props app.UseMigrationsEndPoint(); app.UseHttpsRedirection(); + app.UseStaticFiles(); + app.UseRequestLocalization(options => + { + options.SetDefaultCulture("en-US"); + }); + app.UseRouting(); app.UseAuthentication(); diff --git a/Props/locales/Pages/Index.en-US.resx b/Props/locales/Pages/Index.en-US.resx new file mode 100644 index 0000000..6188cb5 --- /dev/null +++ b/Props/locales/Pages/Index.en-US.resx @@ -0,0 +1,16 @@ + + + + Props is a community driven website meant to help with organizing your online component shopping experience. Create project component lists, search across multiple commonly used online retail stores and share your projects with rest of the community! + + + Getting Started + + + Props is a site designed to help with the online project component shopping experience. Create project component lists and search across multiple commonly used online retail stores to find the ideal purchase. + + + + \ No newline at end of file