|
@@ -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;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|