Seamus 3 ay önce
ebeveyn
işleme
df107768ed

+ 2 - 0
ERP.Application/ERP.Application.csproj

@@ -12,4 +12,6 @@
     <ProjectReference Include="..\ERP.Core\ERP.Core.csproj" />
   </ItemGroup>
 
+  <ProjectExtensions><VisualStudio><UserProperties appsettings_1development_1json__JsonSchema="https://alec016.github.io/Custom-Machinery/Json%20Schema/src/main/resources/schemas/custom_machinery_machine.json" /></VisualStudio></ProjectExtensions>
+
 </Project>

+ 3 - 2
ERP.Core/Application.cs

@@ -96,17 +96,18 @@ namespace ERP.Core
 
         public static void InitConfigure(this IApplicationBuilder app)
         {
-            app.UseAuthenticationMiddleware();
             app.UseHttpsRedirection();
+
             app.UseI18N();
 
+            app.UseAuthenticationMiddleware();
+
             app.UseSwagger();
             app.UseSwaggerUI();
 
             app.UseRouting();
             app.UseEndpoints(endpoints =>
             {
-                //  endpoints.MapMetrics();
                 endpoints.MapControllers();
             });
         }

+ 26 - 0
ERP.Framework/Extensions/I18NExtension.cs

@@ -3,6 +3,7 @@
 // <description></description>
 
 using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Localization;
 using System.Globalization;
 
@@ -22,7 +23,32 @@ namespace ERP.Framework.Extensions
                 options.DefaultRequestCulture = new RequestCulture("en-US");
                 options.SupportedCultures = supporttedCultures;
                 options.SupportedUICultures = supporttedCultures;
+                options.RequestCultureProviders = new List<IRequestCultureProvider>
+                {
+                    new LangCultrueProvider(),
+                };
             });
         }
     }
+
+    public class LangCultrueProvider : RequestCultureProvider
+    {
+        /// <inheritdoc />
+        public override Task<ProviderCultureResult?> DetermineProviderCultureResult(HttpContext httpContext)
+        {
+            if (httpContext == null)
+            {
+                throw new ArgumentNullException(nameof(httpContext));
+            }
+
+            var lang = httpContext.Request.Headers["lang"].ToString();
+
+            if (!lang.IsNullOrEmpty())
+            {
+                return Task.FromResult<ProviderCultureResult?>(new ProviderCultureResult(lang));
+            }
+
+            return NullProviderCultureResult;
+        }
+    }
 }